This write up is about running multiple instances of Apache HTTPD on a Linux system. I tested by running two instances but I understand similar approach would work if more than two instances are required to run independently on a Linux system.
One can easily setup more than one instance by installing two or more HTTPD servers but this piece of writing is not about that rather it talks about how one can copy/modify an existing set of files from a running Apache HTTPD server and set up a completely independent HTTPD instance.
Here is how;
[ It assumed that one HTTPD server is installed by yum and is existing on the system. If not, then install it by yum as; yum install httpd. ]
1. Copy all the files /etc/httpd to a location of your choice. Provide a different name for the
destination e.g. httpd2
# cp -a /etc/httpd /etc/httpd2
2. Copy the existing httpd init script as;
# cp /etc/init.d/httpd /etc/init.d/httpd2
3. Copy the existing sysconfig file for httpd as;
# cp /etc/sysconfig/httpd /etc/sysconfig/httpd2
4. Copy existing 'apachectl' as;
cp -a /usr/sbin/apachectl /usr/sbin/apachectl2
5. Edit '/usr/sbin/apachectl2' as;
if [ -r /etc/sysconfig/httpd2 ]; then
. /etc/sysconfig/httpd2
fi
6. Create soft link as;
# ln -s /usr/sbin/httpd /usr/sbin/httpd2
7. Edit the following /etc/sysconfig/httpd2 as;
HTTPD=/usr/sbin/httpd2
OPTIONS="-f /etc/httpd2/conf/httpd.conf"
LOCKFILE=/var/lock/subsys/httpd2
PIDFILE=/var/run/httpd2/httpd2.pid
8. Edit /etc/init.d/httpd2 as;
if [ -f /etc/sysconfig/httpd2 ]; then
. /etc/sysconfig/httpd2
fi
And, also;
prog=httpd2
9. Edit the following in "/etc/httpd2/conf/httpd.conf" as;
a. Listen 90
b. ServerRoot "/etc/httpd2"
c. PidFile run/httpd2.pid
d. DocumentRoot "/opt/httpd2"
(Change this to your need)
e.
10. Do the following;
a. # cd /etc/httpd2
b. # mkdir -p /var/run/httpd2
# chgrp apache /var/run/httpd2
c. Remove the old link and create a new one with the current path;
# rm run
# ln -s /var/run/httpd2 run
d. # mkdir -p /var/log/httpd2
e. # rm logs
f. # ln -s /var/log/httpd2/ logs
11. Start the services;
[root@Fedora-14 httpd2]# service httpd start
Starting httpd: [ OK ]
[root@Fedora-14 httpd2]# service httpd2 start
Starting httpd2: [ OK ]
12. Check if the ports are listening;
[root@Fedora-14 httpd2]# netstat -apn | grep httpd
tcp 0 0 :::80 :::* LISTEN 5390/httpd
tcp 0 0 :::90 :::* LISTEN 5413/httpd2
13. Check service status;
[root@Fedora-14 httpd2]# service httpd2 status
httpd2 (pid 5413) is running...
[root@Fedora-14 httpd2]# service httpd status
httpd (pid 5390) is running...
14. Stop the services;
[root@Fedora-14 httpd2]# service httpd stop
Stopping httpd: [ OK ]
[root@Fedora-14 httpd2]# service httpd2 stop
Stopping httpd2: [ OK ]
One can easily setup more than one instance by installing two or more HTTPD servers but this piece of writing is not about that rather it talks about how one can copy/modify an existing set of files from a running Apache HTTPD server and set up a completely independent HTTPD instance.
Here is how;
[ It assumed that one HTTPD server is installed by yum and is existing on the system. If not, then install it by yum as; yum install httpd. ]
1. Copy all the files /etc/httpd to a location of your choice. Provide a different name for the
destination e.g. httpd2
# cp -a /etc/httpd /etc/httpd2
2. Copy the existing httpd init script as;
# cp /etc/init.d/httpd /etc/init.d/httpd2
3. Copy the existing sysconfig file for httpd as;
# cp /etc/sysconfig/httpd /etc/sysconfig/httpd2
4. Copy existing 'apachectl' as;
cp -a /usr/sbin/apachectl /usr/sbin/apachectl2
5. Edit '/usr/sbin/apachectl2' as;
if [ -r /etc/sysconfig/httpd2 ]; then
. /etc/sysconfig/httpd2
fi
6. Create soft link as;
# ln -s /usr/sbin/httpd /usr/sbin/httpd2
7. Edit the following /etc/sysconfig/httpd2 as;
HTTPD=/usr/sbin/httpd2
OPTIONS="-f /etc/httpd2/conf/httpd.conf"
LOCKFILE=/var/lock/subsys/httpd2
PIDFILE=/var/run/httpd2/httpd2.pid
8. Edit /etc/init.d/httpd2 as;
if [ -f /etc/sysconfig/httpd2 ]; then
. /etc/sysconfig/httpd2
fi
And, also;
prog=httpd2
9. Edit the following in "/etc/httpd2/conf/httpd.conf" as;
a. Listen 90
b. ServerRoot "/etc/httpd2"
c. PidFile run/httpd2.pid
d. DocumentRoot "/opt/httpd2"
(Change this to your need)
e.
a. # cd /etc/httpd2
b. # mkdir -p /var/run/httpd2
# chgrp apache /var/run/httpd2
c. Remove the old link and create a new one with the current path;
# rm run
# ln -s /var/run/httpd2 run
d. # mkdir -p /var/log/httpd2
e. # rm logs
f. # ln -s /var/log/httpd2/ logs
11. Start the services;
[root@Fedora-14 httpd2]# service httpd start
Starting httpd: [ OK ]
[root@Fedora-14 httpd2]# service httpd2 start
Starting httpd2: [ OK ]
12. Check if the ports are listening;
[root@Fedora-14 httpd2]# netstat -apn | grep httpd
tcp 0 0 :::80 :::* LISTEN 5390/httpd
tcp 0 0 :::90 :::* LISTEN 5413/httpd2
13. Check service status;
[root@Fedora-14 httpd2]# service httpd2 status
httpd2 (pid 5413) is running...
[root@Fedora-14 httpd2]# service httpd status
httpd (pid 5390) is running...
14. Stop the services;
[root@Fedora-14 httpd2]# service httpd stop
Stopping httpd: [ OK ]
[root@Fedora-14 httpd2]# service httpd2 stop
Stopping httpd2: [ OK ]
No comments:
Post a Comment