Multi-Apachectl
By Yaniv Yemini
Description
Multi-Apachectl is a set of scripts that will help you manage multiple instances of Apache 2.2.
It is distributed under the Apache 2.0 license.
- multi-httpd - is a script that replaces Apache's default init.d script (httpd), and which will automatically start and stop all Apache instances.
- multi-apachectl - is a replacement script for apachectl that is bundled with Apache. It will allow you to control each Apache instance separately.
How to use the scripts
To control an Apache instance, use multi-apachectl, just like you would use the original apachectl that comes with Apache,
but with the server instance's root directory name as the first argument:
multi-apachectl www start
In this example, the first argument "www" is the Apache instance's ServerRoot directory name (see How to Install the scripts for an example of how to set up the server instances).
The second argument for multi-apachectl is one of the control commands that you would normally use with Apache's apachectl:
- start - start httpd
- stop - stop httpd
- restart - restart httpd if running by sending a SIGHUP or start if not running
- fullstatus - dump a full status screen (requires lynx and mod_status enabled)
- status - dump a short status screen (requires lynx and mod_status enabled)
- graceful - do a graceful restart by sending a SIGUSR1 or start if not running
- graceful-stop - do a graceful stop of the server.
- configtest - do a configuration syntax test
- help - display help
How to Install the scripts
Following are instructions how to use the scripts.
Create ServerRoot directories
The first step is to create an Apache ServerRoot for each instance of Apache under one base directory.
In this example, we will use /usr/local/apache/sites as the base directory:
/usr/local/apache/sites
www/
blog/
forum/
Each subdirectory under /usr/local/apache/sites is an Apache ServerRoot directory with the following structure:
- conf - configuration dir, with http.conf.
- logs - server logs dir
- modules - a symbolic link to the Apache's installation modules directory.
Configure httpd.conf
Configure each instance httpd.conf so paths to the logs, LoadModule, DocumentRoot and other directives will point to the correct locations.
Install Multi-Apachectl scripts
First, we'll install the multi-apachectl script, which controls the starting and stopping of Apache.
- Download multi-apachectl.tar.gz by clicking on the download link below.
- Unzip and untar the file:
tar -xzf multi-apachectl.tar.gz
- Copy the file multi-apachectl into the bin directory of your Apache installation. It should be placed under the same parent directory as Apache's original apachectl script.
cp multi-apachectl /usr/local/apache/bin
- Copy multi-httpd to your init.d directory (the exact location depends on your Linux/Unix distribution):
cp multi-httpd /etc/init.d/
- Edit the following in multi-apachectl:
HTTPD - set to the path of Apache's binary (httpd).
APACHE_INSTANCES_BASEDIR - set it to the base directory (see "Create ServerRoot directories" above).
The next step is to setup multi-httpd, which is the init.d script that is responsible of starting and stopping Apache instanaces during boot and shutdown of the server.
- Setup multi-httpd to run during boot and shutdown of the server.
Usually, this involves copying multi-httpd to your init.d directory, and then use chkconfig utility tell the system when to call the script during boot and shutdown processes.
- Edit the following in multi-httpd to reflect the paths on your system:
httpd - the path to httpd
pidfile - the path to Apache's PID (process id) file.
APACHE_INSTANCES_BASEDIR - set it to the base directory (see "Create ServerRoot directories" above).
Download
Download the latest version of Multi-Apachectl for Apache 2.2:
multi-apachectl-2.2-v0.5.tar.gz
Comments and feedback
© Yaniv Yemini, 1998-2010