Togotutor Blog Join US!

Enter your email address:

Delivered by FeedBurner

Run Multiple Apache On Single Host

In this blog post we are going to discuss on how to run two Apache instances on single Linux host.

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/togohttpd

  cp -pr /etc/httpd  /etc/togohttpd   

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

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

ServerRoot “/etc/httpd”  TO ServerRoot “/etc/togohttpd”

Listen 80 TO Listen 82

PidFile run/httpd.pid TO PidFile run/togohttpd.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/togohttpd 

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

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

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

 ln -s  /usr/sbin/httpd   /usr/sbin/togohttpd 

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


## CUSTOM SETTINGS ##
HTTPD=/usr/sbin/togohttpd
OPTIONS="-f /etc/togohttpd/conf/httpd.conf"
LOCKFILE=/var/lock/subsys/togohttpd
PIDFILE=/var/run/togohttpd.pid

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

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

  • /etc/init.d/httpd {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}
  • /etc/init.d/togohttpd {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}



Comments

  1. Joshua Chee says:

    Hi, thank you for your wonderful guide, however i am stuck at certain parts.

    I am using opensuse12.2, and the format is different from your tutorial.

    my apache is in /etc/apache2 thus i changed all the commands from /etc/httpd to that
    am able to copy the apache2 directory to apache22
    edited every line in httpd.conf from apache2 to apache22 as there is no server root
    edited my listen.conf to my ip and port
    copied the RHEL config
    copied the init.d file

    however i was unable to locate the setting for “PidFile run/httpd.pid TO PidFile run/togohttpd.pid”

    now my apache can run 2 instances, however i am unable to restart or stop them as the system will detect that the apache is not running.

  2. Hi Joshua,
    I have made some tweaks to the tutorial, please follow the steps by step process and let me know if you see any problems.

Speak Your Mind

*

CAPTCHA Image

*

Visit Us On TwitterVisit Us On FacebookVisit Us On PinterestVisit Us On YoutubeCheck Our Feed