Run Apache and lighttpd on same port 80
In a short description, lighttpd is a *ligthy* webserver which helps to increase the site load speed with a small memory consumption.
Now, I assume that you have already installed both apache and lighttpd in the server.
The main thing should be noted here is we need to have 2 IP’s in the server so that we can run both apache and lighttpd in the same port but on specific and dedicated IP addresses.
Go to apache configuration (CentOS/Fedora/RHEL: /etc/httpd/conf/httpd.conf) and locate the “Listen” directive.
Once you are there, you will probably see “Listen :80″ which tells apache to listen on ALL the interfaces. You will need to change this to make apache listen on just one of your IP addresses ie:
Pick one for apache and do the same for the lighttpd configuration(CentOS/Fedora/RHEL: /etc/lighttpd/lighttpd.conf) but in this case use the other free IP address.
Now, restart apache and then lighttpd. You can try to access IP in browser and make sure both are listening on port 80.
How to increase the MaxClients value greater than the current HARD_SERVER_LIMIT set for Apache.
1. Check if there is any hard server limit.
/usr/local/apache/bin/httpd -V | grep HARD_SERVER_LIMIT
2. Look for this directive in the Apache’s header file /usr/local/apache/include/httpd.h
3. Edit this file and increase the HARD_SERVER_LIMIT as per your requirement.
4. Recompile Apache using
5. There you will have an option to increase the Apache HARD_SERVER_LIMIT, since easyapache looks for the header files and sees the new value while build. By default the MaxClients value will be 256.
Once the build completes, you can see the new HARD_SERVER_LIMIT.
How to redirect port using IPTABLES
You can redirect the port in IPTABLES using the prerouting parameter.
Following is the command you can use to redirect the traffic of the SMTP server port 587 to port 25.
This is very useful when your ISP may have the SMTP port 25 blocked so you need an additional SMTP port to connect to send emails.
iptables -t nat -I PREROUTING -p tcp –dport 587 -j REDIRECT –to-port 25
Then Run iptables save
/etc/init.d/iptables save
Restart Iptables
/etc/init.d/iptables restart
How to install VNC Server.
For RHEL5 or Centos
yum groupinstall “KDE (K Desktop Environment)”
yum install vncserver
Edit the lines below in the file /etc/sysconfig/vncservers and add a user “test1″
(user should be a valid user).
VNCSERVERS=”1:test1″
VNCSERVERARGS[1]=”-geometry 1024×768 -depth 16″
To add more users, just add the lines in the next box below for second user. You can continue with more number of users.
Now the port for user one is 5900+1=5901, The port for user two is 5900+2=5902 and so on.
VNCSERVERS=”2:newuser”
VNCSERVERARGS[2]=”-geometry 1024×768 -depth 16″
Add a password
$ vncpasswd
Password:
Verify:
Edit the startup script
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
/etc/X11/xinit/xinitrc: Bourne-Again shell script text executable
Go for Reboot. When the server is back type the command below to start the VNC server.
Connect to VNC server from your local machine.
(Dont forge to allow 5901 in your firewall.)
Now you can login using the login created previously.
Using SFTP if the default ssh port is changed
Usually if the SFTP is enabled in your server, it will try to use the default SSH port (port 22) even though the SSH service may be running on another SSH port (ie: port 2222).
In this case, the SSH port is running on 2222.
Since SFTP will attempt to connect to port 22, you will have to specify a non-default port for SSH connections so SFTP can issue a proper connection to the remote destination. You can accomplish this by running the following command.
#sftp -oPort=2222 root@Server-IP-address