Can RHEL 4 have two instances of apache httpd running using two different config files?
Solution 1:
In a typical environment, you can create a copy of httpd.conf and then modify the following properties on the new file.
# pid file PidFile run/httpd.pid # http listen port Listen 80 # log files ErrorLog logs/error_log CustomLog logs/access_log combined # server name ServerName default_host_name # document root for the default site DocumentRoot "/var/www/html"
And depending on your implementation you may need to modify additional properties like LockFile (if you are running on a NFS)
And as always you will have to customize the virtual host definitions if you use them.
Controlling the new instance
Say for example if the name of the newly copied file is /etc/httpd/conf/instance1.conf, then you can start this new instance using the following command
httpd -f /etc/httpd/conf/instance1.conf -k start
Another useful option of the httpd command will be the -t option to test the configuration file for errors.
httpd -f /etc/httpd/conf/instance1.conf -t
See 'man 8 httpd' for more information on how to use httpd command.
And as others hinted, you could should create a separate init script to help you manage this instance. The stock RH /etc/init.d/httpd script should act as a starting point.
Solution 2:
Yes, it's quite simple. You basically just have to start up the second instance with a non-default config file on the command line. If you do a web search for "apache multiple instances" you should find what you need.
Solution 3:
Create 2 init scripts, both pointing out to different config files (-f option). Remember to make 2 different pid files .
Solution 4:
Having 2 different config files gets you part of the way there. In addition to the PID files that Kristaps mentioned, you will need to either listen on different ports (other than 80 and 443) or bind to a different interface.
Solution 5:
Copy over the config files under /etc/httpd to another directory. Modify them, changing the ServerRoot, DocumentRoot and other path related variables in httpd.conf and others. Then create a separate init script that call httpd -f