We need to start multiple web server on the same box (CentOS/RHEL). How to implement two httpd servers on a single RHEL machine? Is it supported to run multiple instances of httpd on one RHEL system?
CentOS/RHEL distributions don’t inherently provid a convenient way of doing this, though it is possible to configure manually. There are different ways to configure multiple instances, one option is to:
Duplicate http configuration files,pid,lockfile etc.
1. Duplicate httpd.conf on the system.
# cp -p /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd2.conf
2. Duplicate configuration file /etc/httpd/conf.d on the system.
# cp -pr /etc/httpd/conf.d /etc/httpd/conf.d2
3. Change the pid file’s name, the listen port number, and the conf.d’s file name in /etc/httpd/conf/httpd2.conf as follows.
# vi /etc/httpd/conf/httpd2.conf PidFile run/http.pid2 Listen 8081 Include conf.d2/*.conf
Here, you could also change the listen port number like this if you would like to bind the service to a specified IP:
Listen [IP address]:[PORT Number]
4. Change the listen port number in /etc/httpd/conf.d2/nss.conf and /etc/httpd/conf.d2/ssl.conf if you have mod_ssl and nss installed.
5. Start the second instance of httpd as below:
# /usr/sbin/httpd -f /etc/httpd/conf/httpd2.conf -k start
Under RHEL 7 there would be the option to configure systemd to run the second instance as a service, follow the post below for detail on how to perform that configuration.
6. Start the first instance of httpd by
# service httpd start
7. Confirm that both httpd processes are running.
root 12363 2.0 0.7 218936 7152 ? s 22:52 0:00 /usr/sbin/httpd -f /etc/httpd/conf/httpd2.conf apache 12365 0.0 0.4 219072 4152 ? S 22:52 0:00 /usr/sbin/httpd -f /etc/httpd/conf/httpd2.conf apache 12366 0.0 0.4 219072 4152 ? S 22:52 0:00 /usr/sbin/httpd -f /etc/httpd/conf/httpd2.conf apache 12420 0.0 0.4 219072 4132 ? S 23:05 0:00 /usr/sbin/httpd apache 12421 0.0 0.4 219072 4132 ? S 23:05 0:00 /usr/sbin/httpd root 12423 0.0 0.0 61220 788 pts/0 R+ 23:05 0:00 grep http
Running multiple httpd instances on an RHEL system is supported. It should be noted though that Red Hat is not performing any tests for running multiple instances using in-box service script of httpd package. Multiple other topics may need consideration, i.e. configuring logrotate to account for the logs of the additional instances, and so on.