Subdomains not working with virtual hosts on apache2 ubuntu
        Posted  
        
            by 
                cy834sh4rk
            
        on Server Fault
        
        See other posts from Server Fault
        
            or by cy834sh4rk
        
        
        
        Published on 2012-10-08T01:04:42Z
        Indexed on 
            2012/10/09
            9:41 UTC
        
        
        Read the original article
        Hit count: 375
        
I'm trying to set up a subdomain on my ec2 account but can't figure out what's going on. I've looked for a few hours and haven't been able to find an answer :-/
I'm trying to set up a subdomain using virtual hosts but no matter what I try the browser can't find the subdomain :-(
I have the following vhosts files set up:
apache2/sites-available/mysite (this site currently works)
    <VirtualHost *:80>
        ServerName mysite.com
        ServerAdmin webmaster@localhost
        DocumentRoot /home/sites/mysite
        <Directory /home/sites/mysite>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/mysite-error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/mysite-access.log combined
    </VirtualHost>
apache2/sites-available/red (this is the subdomain I'm trying to set up)
    <VirtualHost *:80>
        ServerName red.mysite.com
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/red
        <Directory /var/www/red>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/red-error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/red-access.log combined
    </VirtualHost>
Apache mod_rewrite is enabled.
I've enabled both sites using a2ensite and I make sure I restart apache every time I make a change.
/etc/hosts
    127.0.0.1 localhost
    127.0.0.1 mysite.com
    127.0.0.1 red.mysite.com
Any help would be appreciated.
Thanks!
© Server Fault or respective owner