9

I operate a VPS on Digital Ocean running Ubuntu 12.04.3, with virtual hosts. I was able to set things up following this tutorial here: https://www.digitalocean.com/community/articles/how-to-set-up-apache-virtual-hosts-on-ubuntu-12-04-lts

However, after a few days I navigated to my main domain (noelforte.com) to check and see if everything was running smoothly, but instead of seeing the landing page that I had temporarily set up, I instead was greeted with a directory listing.

Oddly enough, the subdomain I had configured with VHosts was still pointed to the right directory, however my main domain reverted to pointing at the default document root of /var/www.

Deleting the config files in /etc/apache2/sites-available and setting everything up again yielded the same results: any subdomain will point to the right location, however the root TLD remains stuck pointing to /var/www.

What might cause a situation like this, and why then did it initially work properly?

11

Solved it! Running sudo apache2ctl -S returned the following:

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
         default server noelforte.com (/etc/apache2/sites-enabled/000-default:1)
         port 80 namevhost noelforte.com (/etc/apache2/sites-enabled/000-default:1)
         port 80 namevhost media.noelforte.com (/etc/apache2/sites-enabled/media.noelforte.com:1)

I decided to disable all sites including the default and just activate the sites that I needed. That resolved my problem.

If someone could explain why noelforte.com was running as default-000 as seen here:

port 80 namevhost noelforte.com (/etc/apache2/sites-enabled/000-default:1)

that would help shed some light on what may have been misconfigured. Thanks!

  • I had the same issue, for me it was because the ServerName was set the same as the domain in the 000-default file. – Hard-Boiled Wonderland Feb 7 '14 at 7:19
1

Create a 000-default file in /etc/apache2/sites-available or, if it already exists, edit it. It's where your web server will point if there's no virtualhost defined for the site you are looking up.

Make sure to check that the file also exists in /etc/apache2/sites-enabled. If it doesn't: ln -s /etc/apache2 sites-available/000-default /etc/apache2/sites-enabled/

  • There is a default file already in my /etc/apache2/sites-available directory. I also have a virtual host for noelforte.com set up and enabled, however, it doesn't point to the document root defined in the vhost file. Why? – Noel Forte Dec 23 '13 at 16:34
0

You need to edit /etc/apache2/sites-enabled/yourdomain.conf and add "ServerName" to "yourdomain" . Ex :

<VirtualHost *:80>
    ServerName MyDomain
    DocumentRoot /var/www/myDomainFolder
...
</VirtualHost>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.