# Sub domains



## dpalme (Nov 10, 2009)

I am now attempting to setup a sub domain and having a tad bit of a problem.  It is a virtual host  that is named based.

Here is what I have setup in the httpd-vhosts.conf file:


```
<VirtualHost blog.dougpalme.com:80>
    ServerName blog.dougpalme.com
    DocumentRoot "/home/dougpalme/www/data/blog"
</VirtualHost>

<VirtualHost dougpalme.com:80>
    ServerAdmin webmaster@dougpalme.com
    DocumentRoot "/home/dougpalme/www/data"
    ServerName dougpalme.com
    ServerAlias www.dougpalme.com
    ScriptAlias /cgi-bin/ "/home/dougpalme/www/cgi-bin/"
    ErrorLog "/home/dougpalme/www/logs/error_log"
    CustomLog "/home/dougpalme/www/logs/access_log" combined

    <Directory "/home/dougpalme/www">
        Options -Indexes FollowSymLinks
        AllowOverride AuthConfig FileInfo
        Order allow,deny
        Allow from all
    </Directory>


</VirtualHost>
```

The main host is working fine, however when I go to blog.dougpalme.com it resolves back to the primary site, instead of displaying what is in that directory.

Suggestions?


----------



## aragon (Nov 10, 2009)

Try this:


```
NameVirtualHost 64.150.176.124:80

<VirtualHost 64.150.176.124:80>
    ServerName blog.dougpalme.com
    DocumentRoot "/home/dougpalme/www/data/blog"
</VirtualHost>

<VirtualHost 64.150.176.124:80>
    ServerAdmin webmaster@dougpalme.com
    DocumentRoot "/home/dougpalme/www/data"
    ServerName dougpalme.com
    ServerAlias www.dougpalme.com
    ScriptAlias /cgi-bin/ "/home/dougpalme/www/cgi-bin/"
    ErrorLog "/home/dougpalme/www/logs/error_log"
    CustomLog "/home/dougpalme/www/logs/access_log" combined

    <Directory "/home/dougpalme/www">
        Options -Indexes FollowSymLinks
        AllowOverride AuthConfig FileInfo
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
```


----------



## dpalme (Nov 10, 2009)

I made that change and all I am getting now in the /var/log/httpd-error.log is "client denied by server configuration"


----------



## aragon (Nov 10, 2009)

Ah.  Try this then:


```
<Directory "/home/dougpalme/www">
    Options -Indexes FollowSymLinks
    AllowOverride AuthConfig FileInfo
    Order allow,deny
    Allow from all
</Directory>

NameVirtualHost 64.150.176.124:80

<VirtualHost 64.150.176.124:80>
    ServerName blog.dougpalme.com
    DocumentRoot "/home/dougpalme/www/data/blog"
</VirtualHost>

<VirtualHost 64.150.176.124:80>
    ServerAdmin webmaster@dougpalme.com
    DocumentRoot "/home/dougpalme/www/data"
    ServerName dougpalme.com
    ServerAlias www.dougpalme.com
    ScriptAlias /cgi-bin/ "/home/dougpalme/www/cgi-bin/"
    ErrorLog "/home/dougpalme/www/logs/error_log"
    CustomLog "/home/dougpalme/www/logs/access_log" combined
</VirtualHost>
```


----------



## dpalme (Nov 10, 2009)

I assume that part of the difference was moving the <directory> outside the <VirtualHost> tags.

I am not sure I quite understand that, if I recall, we used to include those within the virtual host tags, but again maybe not.  It has been five years.

Thank you for the assistance, I think I am just about finished.....


----------

