1

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!

1
  • 1
    This question might belong to serverfault.
    – BudwiseЯ
    Oct 8, 2012 at 1:07

2 Answers 2

1

How to debug all similar errors:

1) make sure the domain red.whatever.com is pointing to the correct ip

How to do this? Use a tool like DIG on linux/osx or resort to an online tool.
the common error the browser reports in such a case is COULD NOT FIND DOMAIN...

2) If the IP is correct check both Apache logs (error.log and access.log)

If there is no information on these logs check your firewall to see if port 80 is open.
the common error on the browser reports in such case is COULD NOT CONNECT...

3) IP is correct, port is open, Apache is not serving the content you were expecting

The solution to your problem will be given by the log files
the browser will show a 404 or a similar http error sent by the server...

EDIT: from your comment your problem is on number 1.

11
  • yes, I'm aware of the difference in the <Directory> paths. I tried making a new directory in /home/sites for the subdomain but it still didn't work. As far as being able to ping the domains, yes, both commands ping the same IP... I don't get any errors on the apache error log :-/
    – cy834sh4rk
    Oct 8, 2012 at 1:38
  • and actually I don't think the message is not getting to EC2 since I don't see anything in the access.log file. Is there anything I need to do on the AWS side to make this work?
    – cy834sh4rk
    Oct 8, 2012 at 1:51
  • @user1667234 "I don't think the message is not getting to EC2" this double negative would mean that you do think the message is getting there was it a typo? Check both the access.log and the error.log and, most of all, what does the browser respond with? (what do you see on screen when you try to access the site?)
    – Frankie
    Oct 8, 2012 at 11:08
  • ...sorry about the confusion. When I go to red.mysite.com I don't see any logs on either error.log or access.log, that's why I said I don't think I can hit the server - because I don't see anything on the apache logs. Chrome shows a message saying "Oops! Google Chrome could not find red.mysite.com"
    – cy834sh4rk
    Oct 9, 2012 at 2:23
  • @cy834sh4rk that message from Google Chrome means the the domain is badly configured. red.mysite.com is NOT pointing to the IP it should be.
    – Frankie
    Oct 9, 2012 at 14:34
1

Does the NameVirtualHost directive (e.g., NameVirtualHost *:80) appear in your configuration file before the virtual hosts sections? If not, all requests will go to the first vhost.

5
  • I tried adding the following line to both files NameVirtualHost *:80 and when I restart apache I get the following warning message: * Restarting web server apache2 [Tue Oct 09 02:31:12 2012] [warn] NameVirtualHost *:80 has no VirtualHosts ... waiting [Tue Oct 09 02:31:13 2012] [warn] NameVirtualHost *:80 has no VirtualHosts The subdomain still does not work :-/
    – cy834sh4rk
    Oct 9, 2012 at 2:33
  • Add it before the VirtualHost sections.
    – Dondi Michael Stroma
    Oct 9, 2012 at 3:23
  • Thanks for your help! I did. I tried adding it to both files before the <VirtualHost *:80> section and I also tried adding it to one file only. I still get the same warning message when restarting apache.
    – cy834sh4rk
    Oct 9, 2012 at 3:48
  • No, add it in the main configuration file. And while you're add it, check to make sure the line to include sites-available is not commented it out.
    – Dondi Michael Stroma
    Oct 9, 2012 at 7:16
  • @Dondi - I'm sorry but I don't know what you mean by "the main configuration file". I tried adding it to http.conf and the default vhost but that didn't help.
    – cy834sh4rk
    Oct 10, 2012 at 2:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .