Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Setting up a dev LAMP server and I wish to allow dynamic subdomains, aka,

Here's my sites-active file

<VirtualHost *:80>
    # Admin Email, Server Name, Aliases
    ServerAlias     *

    # Index file and Document Root
    DirectoryIndex  index.html
    DocumentRoot    /home/sysadmin/public_html/

    # Custom Log file locations
    LogLevel        warn
    ErrorLog        /home/sysadmin/public_html/
    CustomLog       /home/sysadmin/public_html/ combined

And here's the output from sudo apache2ctl -S

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
         default server (/etc/apache2/sites-enabled/000-default:1)
         port 80 namevhost (/etc/apache2/sites-enabled/000-default:1)
         port 80 namevhost (/etc/apache2/sites-enabled/
Syntax OK

The server hostname is

As you can see from apache2ctl when I use I get the default virtual host, when I use a subdomain, I get the host. So the later is working how I want, but the main url does not.

I've tried all kinds of variations here, but it appears that ServerName just isn't being tied to the correct location.

Thoughts? I'm stumped. FYI, I'm running Apache2.1 and Ubuntu 10.04 LTS

share|improve this question
NOTE, I just replaced *:80 with the IP and both the servername and serveralias now work. But am I going to run into the same thing if I setup a second site listing on the same IP? – CreativeNotice May 23 '10 at 21:07
yes... with different servername & serveralias. – risyasin May 24 '10 at 13:41
have you uncomment the line with NameVirtualHost *:80? – Anarko_Bizounours Jun 16 '11 at 7:26

I had almost the exact problem you're having. It stemmed from the default ServerName (in /etc/apache2/conf.d/servername.conf) and the ServerName in my VirtualHost definition file (/etc/apache2/sites-available/ being equal.

share|improve this answer

for each subdomain, create a file just like the one you have listed above, except just give the subdomain as the servername. remove the * as a server alias. enable the config files in apache, and restart apache.

share|improve this answer

I believe what you are looking for will require sections for the hostnames you want the server to respond to. What you have configured currently all port 80 traffic is picked up and pointed at /home/sysadmin/public_html/

Try adding a section and a section with appropriate document roots. This way you can use bill and ted to serve up different content from the same server with the outward look and feel of a different server.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.