Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have my own vps, and I want to add a subdomain to my domain. I figured this is something that apache can handle.

So I'm using someone else's DNS, which points requests of my domain to my server.

I haven't really done anything to mess with the 'stock' install of apache2.

I currently have this in my sites-enabled:

NameVirtualHost x.x.x.x:80

<VirtualHost x.x.x.x:80>
  ServerName www.domain.com
  ServerAlias domain.com
  DocumentRoot /var/www/domain
  AccessFileName .htaccess
  <Directory /var/www/domain>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Order allow,deny
    allow from all
  </Directory>
</VirtualHost>

I tried adding a second virtualhost with the same IP, and just changing any occurrence of domain.com to subdomain.domain.com, but I get an error upon restart saying that I have multiple virtualhosts with the same name or something.

I think there is a simple solution to this, and I have spent enough time trying to figure this out.

share|improve this question

migrated from stackoverflow.com Oct 20 '12 at 23:48

This question came from our site for professional and enthusiast programmers.

    
Don't forget to add the DNS entry for the sub-domain. –  John Gardeniers Oct 21 '12 at 0:07

1 Answer 1

Must be a simple thing that went wrong. Try this very simple example:


    NameVirtualHost *:80

    <VirtualHost *:80>
    DocumentRoot /var/www/domain
    ServerName www.domain.com
    </VirtualHost>

    <VirtualHost *:80>
    DocumentRoot /var/www/sub1
    ServerName sub1.domain.com
    </VirtualHost>

share|improve this answer

Your Answer

 
discard

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