Can RHEL 4 have two instances of apache httpd running using two different config files?

7,715

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

Share:
7,715

Related videos on Youtube

bassen
Author by

bassen

I have been exchanging knowledge for over 11 years, StackExchange just makes it easier. Come and find out which other SE sites I collaborate. Follow me on Twitter.

Updated on September 17, 2022

Comments

  • bassen
    bassen over 1 year

    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?

  • marcin naglik
    marcin naglik almost 15 years
    How is answering a question with 'do a web search' helpful?
  • bassen
    bassen almost 15 years
    I am having trouble adjusting the stock httpd init script. I adjusted the variables and it should be starting with my new config file but is starting the other instance. any ideas?