How to Run Multiple Apache On Single Host


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}

About Alex Hunt

Hi All I am Manish Kumar Jha aka Alex Hunt. I am currently working in VMware Software India Pvt Ltd as Operations System Engineer (vCloud Air Operations). I have around 5 Years of IT experience and have exposure on VMware vSphere, vCloud Director, RHEL and modern data center technologies like Cisco UCS and Cisco Nexus 1000v and NSX. If you find any post informational to you please press like and share it across social media and leave your comments if you want to discuss further on any post. Disclaimer: All the information on this website is published in good faith and for general information purpose only. I don’t make any warranties about the completeness, reliability and accuracy of this information. Any action you take upon the information you find on this blog is strictly at your own risk. The Views and opinions published on this blog are my own and not the opinions of my employer or any of the vendors of the product discussed.
This entry was posted in Server Configuration. Bookmark the permalink.

3 Responses to How to Run Multiple Apache On Single Host

  1. Jose says:

    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

    Like

  2. deepak says:

    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.

    Like

  3. deepak says:

    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.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s