This page was edited more than a year ago (2007-07-25), content might not be relevant or accurate anymore.

Apache Mass Virtual Hosting

Official documentation for Apache's vhost_alias module can be found at Some configurations of mass hosting can be also found there –

Mass virtual hosting is actually quite easy to set up. On Debian you can just put this simple configuration to /etc/apache2/sites-available/vhost, run a2ensite vhost and restart Apache server.

<VirtualHost *>
    # 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 \"%{Referer}i\" \"%{User-Agent}i\"" vcombined
    CustomLog /home/www/logs/access_log vcombined
    ErrorLog /home/www/logs/error_log
    # add '_' and 'www' symlinks pointing to ./ if you want (in /home/www/doamin.tld/)
    # 'www' is not really necessary as it could be a different subdomain
    # also does not resolve by IP, have to create symlinks ( -> 0.1/0)
    # it's not pretty but cheap
    VirtualDocumentRoot /home/www/%-2.0.%-1.0/%-3
    # not used
    #VirtualScriptAlias /home/www/%0/cgi-bin

This configuration has some drawbacks but it's suitable for development workstation or small personal server which can host any number of domains. Subdomains are just directories.

At workstation you can use /etc/hosts for adding testing domains, no need to configure DNS server.

Back to top
howto/apache_mass_virtual_hosting.txt · Last modified: 2007/07/25 21:34 (external edit)
disorder's homepage Valid CSS Valid XHTML 1.0 Recent changes RSS feed