We have a Red Hat Enterprise Linux 4 instance running Apache on the default port. We want to add a second Apache instance that we can restart completely separate from the first instance. Can we do this?
Perhaps is there another easy-to-maintain web server that can run very simple PHP scripts on a non-standard port? We want to be able to trigger a php script remotely without using the default instance of Apache running on the RHEL server. Any ideas?
In a typical environment, you can create a copy of httpd.conf and then modify the following properties on the new file.
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
Another useful option of the httpd command will be the -t option to test the configuration file for errors.
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.
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.
Create 2 init scripts, both pointing out to different config files (-f option). Remember to make 2 different pid files .
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.
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
This is most definately possible. The creation of two init.d scripts to seperate these instances would be the best way to do this, you could actually use the provided 'httpd' script and modify that for your the options to be used in your second instance.
Initd scripts just run the services with the prefered options. You can also start up other instances via the command-line using the binary at any time.
/usr/sbin/apachectl
This is all the init.d script does except it fills in options such as Language, Config File, and other options. Infact, the init.d scripts often reference variables created in other places such as /etc/sysconfig/httpd. Changing variables in that file is for your init.d script, which uses the binary. Its just a chain of moderately simple code.