Skip to content

Apache dynamicaly configured vhosts

I want user to be able set up development sites on a server without the need for creating dns entries or apache vhost files. My current working solution to this has two elements.

Firstly creating a wildcard dns entry. This is a dns entry which starts with a wildcard “*” followed by the domain (or in this case subdomain).

*       A

Any request to will then be directed to the named server regardless of their prefix eg (,

At this point the apache server receiving requests from these hosts will have no idea how to deal with them so we must create a dynamic vhost file.  A detailed description of a dynamic vhosts can be found on the Apache site, but basically what it will do is take the server name from a request and use it to set the document path etc in the vhost dynamically. So using the configuration bellow

# 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 /www/hosts/%0/docs will point to the documents in directory /www/hosts/ and will point to /www/hosts/ So in effect this means all a developer has to do to have an accessible dev site is to create the proper name in the proper directory.

Posted in geek, sysadmin.

Tagged with , , .

10 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Continuing the Discussion

  1. Web Host Header | Host Rage linked to this post on April 5, 2010

    […] Apache dynamicaly configured vhosts – […]

  2. ROLAND linked to this post on July 22, 2010 Canadian Health&Care.No prescription online pharmacy.Best quality drugs.Special Internet Prices. High quality pills. Buy drugs online

    Buy:Advair.Zetia.Acomplia.Nymphomax.Buspar.Cozaar.Zocor.Seroquel.Wellbutrin SR.Lipitor.Female Cialis.Amoxicillin.Female Pink Viagra.Aricept.Ventolin.Prozac.Lasix.Benicar.SleepWell.Lipothin….

  3. HARVEY linked to this post on September 5, 2010 Canadian Health&Care.Special Internet Prices.No prescription online pharmacy.Best quality drugs. Low price drugs. Order pills online

    Buy:Aricept.Lipothin.Lipitor.Acomplia.Prozac.Amoxicillin.Female Cialis.Ventolin.Zocor.Buspar.Zetia.Benicar.Seroquel.Advair.Female Pink Viagra.SleepWell.Cozaar.Nymphomax.Lasix.Wellbutrin SR….

  4. JOSEPH linked to this post on September 6, 2010 Canadian Health&Care.No prescription online pharmacy.Best quality drugs.Special Internet Prices. Low price drugs. Buy drugs online

    Buy:Aricept.Lipothin.Female Cialis.Advair.Prozac.Buspar.Amoxicillin.Ventolin.Acomplia.Nymphomax.Lasix.Wellbutrin SR.SleepWell.Cozaar.Benicar.Zocor.Zetia.Lipitor.Seroquel.Female Pink Viagra….

  5. ZACHARY linked to this post on September 7, 2010 Canadian Health&Care.Special Internet Prices.Best quality drugs.No prescription online pharmacy. No prescription drugs. Order drugs online

    Buy:Buspar.Wellbutrin SR.Zetia.Female Cialis.Female Pink Viagra.Acomplia.Aricept.Lipothin.Ventolin.Lasix.Seroquel.Benicar.Prozac.SleepWell.Amoxicillin.Cozaar.Nymphomax.Advair.Lipitor.Zocor….

  6. CAMERON linked to this post on November 11, 2010

    NEW FASHION store. Original designers collection at low prices!!! 20 % TO 70 % OFF. END OF SEASON SALE!!!


  7. CARLOS linked to this post on December 18, 2010

    ████████►BUY CIALIS◀████████…


  8. KARL linked to this post on December 24, 2010


    Buygeneric pills…

  9. WALTER linked to this post on December 27, 2010

    Buyno prescription…

  10. CLAUDE linked to this post on December 29, 2010

    Buygeneric pills…

You must be logged in to post a comment.