Apache and subdomain

Hi,

I want to have an additional subdomain like this:

mydomain.com
sub.mydomain.com

The problem is that sub.mydomain.com can’t be resolved (gives an “address not found” error when opening in FF).
The “normal” domain mydomain.com is working. I can also ping the subdomain.

In vhosts I have sub.mydomain.com.conf:


<VirtualHost *:80>
    ServerAdmin webmaster@mydomain.com
    ServerName mydomain.com
    DocumentRoot /srv/www/htdocs
    HostnameLookups Off
    UseCanonicalName Off
    ServerSignature On

    <Directory "/srv/www/htdocs">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@sub.mydomain.com
    ServerName sub.mydomain.com
    DocumentRoot /srv/www/vhosts/sub.mydomain.com
    HostnameLookups Off
    UseCanonicalName Off
    ServerSignature On

    <Directory "/srv/www/vhosts/sub.mydomain.com">
	Options Indexes FollowSymLinks
	AllowOverride None
	Order allow,deny
	Allow from all
    </Directory>
</VirtualHost>

There is an index.html file in both directories /srv/www/htdocs/index.html and /srv/www/vhosts/sub.mydomain.com/index.html

listen.conf:


NameVirtualHost *:80

/etc/hosts:


127.0.0.1       localhost
1.2.3.4	        mydomain.com
1.2.3.4	        sub.mydomain.com

Is there anything I’m missing ?

Thanks a lot !

well the line in etc/hosts is incorrect. Aliases should be on the same line:
1.2.3.4 myserver.com second.server.com third_server.com

only the first line ip address is read when there is an inquiry therefore it will never get to the second line.

as in this tutorial(if you want to learn more)
Quick HOWTO : Ch03 : Linux Networking - Linux Home Networking
192.168.1.101 smallfry tiny littleguy