Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set up Mass Virtual Hosting on Apache.

VirtualHosts

How to set up Mass Virtual Hosting on Apache.

by  Wullie  Posted    (Edited  )
Code:
Hi, This explains how to set up basic mass virtual hosting on Apache.

This is very useful if you are adding virtualhosts at different times as you do not need to keep restarting apache every time you add a new site. 

In these instructions, I am assuming that you already have virtualhosts set up and working. If you do not, then please read the faq on how to set up virtualhosts first!!

Firstly, backup your httpd.conf in case there are any problems with the set-up.

Now uncomment the following two lines..

LoadModule vhost_alias_module modules/mod_vhost_alias.so

AddModule mod_vhost_alias.c

Add the following to the very bottom of the httpd.conf. If you already have virtualhost directives then you need to replace them.. 

#
# Set up the mass virtual hosting
#
<VirtualHost *:80>
   UseCanonicalName off
   VirtualDocumentRoot /www/%0
   VirtualScriptAlias /www/%0/cgi-bin
   ServerSignature EMail
</VirtualHost>
# End mass hosting set up

To explain how this works: Apache will replace %0 with the actual full domain that is requested. So, for example, if the visitor requested www.mydomain123.com then apache will look for the DocumentRoot in /www/www.mydomain123.com and the cgi-bin in /www/www.mydomain123.com/cgi-bin

You now need to configure the directories with your files in them to correspond with this set-up. Change all your virtualhost directories to the FULL domain name. So www.me.com would be called from /www/www.me.com and so on.. 

To set up subdomains, just change the directory name to match.. Eg. subdomain.domain.com would be called from the /www/subdomain.domain.com directory.

If you have scripts with the paths defined, you will also need to alter them to reflect these changes..
Hope this helps

Wullie

sales@freshlookdesign.co.uk
www.freshlookdesign.co.uk
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top