If you want to run some hundreds of virtual hosts on an apache webserver and you configure
the server in the conventional way, with virtual hosts in the httpd.conf, you will qick notice,
that your httpd processes gets quite big (>90M).
Now, every new connection causes this big httpd process to fork. The data segment of the process
only includes configuration information that does not change, so the process does not really need
this space in memory. But Solaris, other than Linux, reserves this 90M in your swapspace.
If you have a heavy loaded server with 400 processes or more, you will need a minimum of
400 times 90M swapace. The swap organisation will keep the Kernel working, but not your webserver.
The Solution
The solution for this scenario could be mod_dynvhost or
mod_pweb. Mod_dynvhost provides you
a directory where you simply create a folder with the name of the domain. This is easy to use, but you
won't be able to do a translation from let's say www.custumerdomain.com to /webdata/customerid.
This functionality is only provided by mod_pweb.
The idea behind mod_pweb is, to have the complete virtual host configuration in one shared memory
segment and then have small httpd processes attaching to this segment to do the domainname to path
resolution.
The Build
Download mod_pweb-0.2b.tgz and unpack it with tar -zxvf mod_pweb-0.2b.tgz.
Change in the mod_pweb-0.2b directory and execute make.
This will build the initshm tool.
Now locate the apxs script which is included in your webserver binary directory. Then execute /PATH_TO_YOUR_APXS/apxs -c mod_pweb.c. After this build, copy the file mod_pweb.so to your
apache libexec directory.
The Configuration
You need to create a file for the domainname to path translations.
This is a simple textfile and it should look like this :
Now you must create the shared memory segment for the httpd processes. The program initshmwhich is part of the mod_pweb tarball is used to do this. Make sure that you
choose an uniqe shared memory key for this segment. You can use the command ipcs -m
to list already installed shared memory blocks. None of the listed blocks must have the same key as
the key you intend to use.
This is the syntax of initshm for the key 0x1234567:
initshm -s 0x1234567 -f YOUR_FILE_NAME
The output of the command should look similar to that:
The shmid = 87809
shm is initialized
Well done.
The next part is the webserver configuration.
This lines must be added to your httpd.conf file to load the module and to do all necessary configurations
for the module to work properly.
is the path where you've installed your mod_pweb.so
SHMKEY
is the uniqe key you've used whit inithash.
The CgiDir provides a possibility to enable global and userspecific cgi execution paths.
For userspecific cgi execusion use $DOCROOT variable in the CgiDir path.
In the example above, cgi scripts under domainname/cgi-bin/... will be executed from /usr/local/apache/cgi-bin/...
while scripts under domainname/mycgi/... are taken from the users document root out of the subdirectory mycgi.
After a start or restart of your webserver you should find this lines in your webservers error_log:
Saving DocRoot: XXXX
Process: XXXX
SHM found with SemId : XXXX
Now the webserver is doing the translation as described in
TODO
- ScriptAlias and exec cgi path should be configurable. - DONE in 0.2b
- Change configuration without restarting the webserver - planned for Rel 1.0 in 06.2003
If you have commits, ideas or patches feel free to mail me.