7

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?

6 Answers 6

9

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.

1
  • 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?
    – Geo
    Jun 26, 2009 at 22:01
3

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.

1
  • 1
    How is answering a question with 'do a web search' helpful?
    – Simurr
    Jun 26, 2009 at 15:59
2

Create 2 init scripts, both pointing out to different config files (-f option). Remember to make 2 different pid files .

2

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.

1

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

1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .