If you want  to run two Apache instances on single Linux host you can do it easily by following the steps as shown below.

We already have one Apache installed and serving the static content. The Apache is installed at the following location:

/etc/httpd

Let`s copy the directory /etc/httpd to /etc/new_httpd

  cp -pr /etc/httpd  /etc/new_httpd

Now, as we have copied the old Apache web-server to a new location /etc/new_httpd. We need to make the changes to the configuration file.

cd  /etc/new_httpd and open the httpd.conf file in a vi editor and make changes to the following values:

ServerRoot “/etc/httpd”  TO ServerRoot “/etc/new_httpd”

Listen 80 TO Listen 82

PidFile run/httpd.pid TO PidFile run/new_httpd.pid

Save and close the file.

In the next step we are going to copy the RHEL httpd configuration file.

 cp -pr /etc/sysconfig/httpd  /etc/sysconfig/new_httpd

In the next step, let`s copy the script /etc/init.d/httpd  TO /etc/init.d/new_httpd

 cp -pr  /etc/init.d/httpd   /etc/init.d/new_httpd

In this step, Link the /usr/sbin/httpd TO /usr/sbin/new_httpd

 ln -s  /usr/sbin/httpd   /usr/sbin/new_httpd

Open the file new_httpd under /etc/sysconfig/ and enter the following lines:

## CUSTOM SETTINGS ##

HTTPD=/usr/sbin/new_httpd

OPTIONS=”-f /etc/new_httpd/conf/httpd.conf”

LOCKFILE=/var/lock/subsys/new_httpd

PIDFILE=/var/run/new_httpd.pid

Open the new_httpd file under /etc/init.d and replace httpd to new_httpd.

The command used to start/stop httpd and new_httpd service could be:

  • /etc/init.d/httpd {start|stop|restart}
  • /etc/init.d/new_httpd {start|stop|restart}
Posted in: Linux.
Last Modified: January 12, 2017

3 thoughts on “How to Run Multiple Apache On Single Host

  1. Jose

    Hello,
    Thank you very much for this post, I have followed the steps you mentioned and I’m able to start two instances of httpd, but I have a problem when I try to stop the new_httpd instance, everytime I try to stop it, I get a FAILED message. Did you experience this problem? Thank you.

    Jose

  2. deepak

    The issue is with new_httpd.pid file location. Please edit belwo path of new_httpd under /etc/sysconfig/ as
    PIDFILE=/var/run/new_httpd/new_httpd.pid

    and Create a new folder new_httpd under /var/run.

    Thsi wouold resolve the issue.

  3. deepak

    If thsi above doesnot work the hard code absolute path of PidFile in new httpd.conf file as

    PidFile /var/run/new_httpd/new_httpd.pid

    Issue is coming because while stoping apache using “/etc/init.d/new_httpd stop”, it searching pid file under “/var/run/new_httpd/” but its created by default under /var/run/new_httpd.pid. By hardcoding pidfile path it resolves the issue.

Leave a reply