| Mass Dyanamic Virtual Hosting Guide |
Dustin's Mass Dyanamic Virtual Hosting Mass Dyanmic Virtual Hosting is basically a means for having many virtual hosts, and one mass configuration. It isn't much use for most people but when I decided to start a free web hosting service, it came in handy. Some of the benefits are: 1. A smaller httpd.conf, this make Apache start faster and take up less memory. 2. Better automation, if you need that sort of thing. To achieve this, you must use mod_vhost_alias, which comes with apache, but is not installed by default. You most likely have installed apache before if you are doing this, if not, you can refer to Joey's Apache Guide or my personal LAMP Guide. I keep my Apache source in /usr/local/src/apache_1.3.11 and I compile the binaries into /usr/local/apache. Your locations can and probably will be different then mine. So without further waiting, let's get on with it. Fisrt you wanna unpack the Apache source and cd into the directory.
tar -zxvf apache_1.3.11.tar.gz cd apache_1.3.11 Then you are going to want to configure Apache with mod_vhost_alias activated and then compile and install. ./configure --prefix=/usr/local/apache --activate-module=src/modules/standard/mod_vhost_alias.c
make make install That should take care of it, of course you will want to add in any other modules you want, like PHP. The rest has to do with the configuration. When you setup mod_vhost_alias and you already have static virtual hosts defined, it creates some conflicts, but they are overcome easily. Here is an example of a standard vhost before and after. Before mod_vhost_alias...
After...
The only thing you should notice is that we changed DocumentRoot to VirtualDocumentRoot. That makes it point to the right place, and resolves any conflicts that would have been made. For this to work, all of your dynamic vhosts need to be in the same type of directory structure. For example, in my free web hosting service, all of the members directories are in /html/members and their directory would look like /html/members/~username. This is very easy. Now, you will want to paste the following lines to the bottom of you httpd.conf # Get the server name from the Host: header
UseCanonicalName Off # This log format can be split per-virtual-host based on the first field
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon CustomLog logs/access_log vcommon # Include the server name in the filenames used to satisfy requests
VirtualDocumentRoot /html/members/%1 VirtualScriptAlias /html/members/%1/cgi-bin There are a few things that you could leave out. I dont offer CGI access so I don't have the VirtualScriptAlias directive. Also, the UseCanonicalName directive is already specified earlier, which is fine, you can have it here and there, or you can just have one but make sure the last one is set to "off". Now, the part that make this dynamic is the "%1" in the VirtualDocumentRoot and the VirtualscriptAlias. there are various choices that you could make here. I chose "%1" because it takes the fist part of the domain, the "subdomain" and uses it for the name. Here is an example.
subdomain.domainname.topleveldomain or: search.cnet.com
There is a list of all of the choices here: Having trouble? Got questions? Require further assistance? If so please feel free to visit our Help Forums and ask the experts! |
|
Copyright © 1997 - 2008 Private World Domination Inc. All rights reserved. |
|