Dynamic Virtualhosting (for subdomains) with apache

| | Comments (0) | TrackBacks (0)

Apache provides a very easy method to provide hosting for dynamically created sub-domains with "VirtualScriptAlias" and "VirtualDocumentRoot" syntaxes

Lets say, we have mydomain.com, and you need to dynamically configure test.mydomain.com, monkey.mydomain.com etc. (and not required to manually configure apache or restart), then..

Step 1: Configure wild-card DNS, so that *.mydomain.com is a cname to mydomain.com

Step 2: Configure apache. Create a new virtualhost section for *.mydomain.com, like:

<VirtualHost *>
ServerAlias *.mydomain.com
CustomLog /www/www.logs/virtual.mydomain.com-access_log combined
ErrorLog /www/www.logs/virtual.mydomain.com-error_log
VirtualDocumentRoot /www/www.mydomain.com/virtualdomains/%0/docs
VirtualScriptAlias  /www/www.mydomain.com/virtualdomains/%0/cgi-bin/
</VirtualHost>

Step 3: Restart apache to activate the new configuration

Step 4: Now, say you need test.mydomain.com, all that is required is to create /www/www.mydomain.com/virtualdomains/test.mydomain.com/docs and /www/www.mydomain.com/virtualdomains/test.mydomain.com/cgi-bin/

 

Technorati Tags: , , ,

0 TrackBacks

Listed below are links to blogs that reference this entry: Dynamic Virtualhosting (for subdomains) with apache.

TrackBack URL for this entry: http://www.megalinux.net/cgi-bin/mt/mt-tb.fcgi/72

Leave a comment

About this Entry

This page contains a single entry by Ram Prasad published on June 19, 2007 2:12 PM.

Tomcat UTF8 Characters was the previous entry in this blog.

Warrick: Restoring website from internet caches is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by
Movable Type 4.01