webserver

How can I run multiple Apache instances on port 80 on my Linux server?

To run multiple instances of Apache on port 80 they need to be listening on different IP addresses.

If you have 1 physical network interface eth0, you can set up multiple virtual interfaces like this:

linuxserver# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
DHCPCLASS=
HWADDR=01:21:9B:8B:B1:BD
ONBOOT=yes
IPADDR=10.20.1.20
NETMASK=255.255.255.0
GATEWAY=10.20.1.1

linuxserver# cat /etc/sysconfig/network-scripts/ifcfg-eth0:0
DEVICE=eth0:0
BOOTPROTO=static
ONBOOT=yes
IPADDR=10.20.1.21
NETMASK=255.255.255.0
GATEWAY=10.20.1.1

The ifcfg-eth0:0 virtual interface has been added and will listen on 10.20.1.21. eth0 listens on 10.20.1.20.

If you have 2 instances of Apache; 1 in /opt/apache-1 and another in /opt/apache-2 you can do the following:

In /opt/apache-1/conf/httpd.conf you have this line:

Listen 10.20.1.20:80

and in /opt/apache-2/conf/httpd.conf you have this line:

Listen 10.20.1.21:80

After starting both Apache instances you can run a netstat -an and you should see both instances running simultaneously.

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

To Top