dave
dave

Reputation: 2298

Sites showing "It Works!" page, not what is specified in vhost configs

It APPEARS I have everything set the right way, after hours of reading/trying a dozen or so tutorials on setting up virtual hosts. Basically, after upgrading my Ubuntu distro (I know, right?), Apache upgraded to 2.4 and everything broke. After trying to figure that out, I just decided I blew everything out and started anew. PHP/Apache are current.

I'm getting the root index ("It Works!") returned, but not the DocumentRoot I specify.

/etc/apache2/sites-available/domain.com.conf

<VirtualHost *:80>
    ServerName domain.com
    ServerAlias www.domain.com

    # Indexes + Document Root
    DirectoryIndex index.php index.html
    DocumentRoot /var/www/domain.com/htdocs/

    # Logging
    ErrorLog  /var/www/domain.com/logs/error.log
    CustomLog /var/www/domain.com/logs/access.log combined

    <Directory "/var/www/domain.com/htdocs/">
            Options Indexes FollowSymLinks Includes
            AllowOverride All
            Require all granted
    </Directory>
</VirtualHost>

I typed in "sudo a2ensite domain.com.conf" and that is showing up in /enabled-sites as you would expect.

apache2ctl -S

VirtualHost configuration:
*:80     is a NameVirtualHost
     default server domain.com (/etc/apache2/sites-enabled/domain.com.conf:1)
     port 80 namevhost domain.com (/etc/apache2/sites-enabled/domain.com.conf:1)
             alias www.domain.com
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33 not_used
Group: name="www-data" id=33 not_used
User: name="www-data" id=33 not_used
Group: name="www-data" id=33 not_used

Hoping that it's something stupid I'm overlooking, because it's been a frustrating night and I've tried everything I can think of so I wouldn't have to bother you folks with this (sorry!). I'm not getting any errors from Apache when I start/restart, nor am I getting anything in any error logs. Not sure this is applicable, but the DirectoryRoot permissions is set to 755.


update (11/05/13)

Apparently the "magical fixer fairy" swooped in and resolved this. There is no cache engine installed to my knowledge (unless Apache 2.4 installs with one by default?), so I'm not sure what could've changed itself to make it resolve to the correct directory over the weekend (in which I did not work), but there you go. Just for the hecklers: yes, I had restarted apache (a million times) so that wasn't the fix.

Upvotes: 3

Views: 29365

Answers (3)

Bas Goossen
Bas Goossen

Reputation: 599

I know this is an old question, but still there was not a real answer. I've experienced the same problem today and it seems that restarting the service with:

service apache2 restart

or reloading with:

service apache2 reload

as suggested by a2ensite "is not enough" or does simply not work. I restarted the service a few times without result. Then i did a:

service apache2 stop

and afterwards restarted the service with:

service apache2 start

And this solved the problem. Strange to see this behaviour but it might be caused by a misconfigured runscript.

Upvotes: 0

user238705
user238705

Reputation: 63

Got the same problem when upgrading to the "saucy" release of Ubuntu. In my case I had several configurations ("sites-available") which did not had the suffix ".conf".

Since the apache2.conf has a directive that only includes enabled sites having this suffix the only configuration that was properly loaded was the default one. Therefore I suggest that you remove all links in the "sites-enabled" folder, make sure that all your configurations in "sites-available" do have the suffix .conf and enable your sites again using the "a2ensite" program!

Regards, Garth

Upvotes: 6

David Cahill
David Cahill

Reputation: 1487

Are you sure the default vhost file isn't what you are hitting? Make sure the only config enabled is your new vhost first using the a2dissite command and restarting apache.

Then check your access logs specified in your vhost to see what it's actually pulling.

# Logging
ErrorLog  /var/www/domain.com/logs/error.log
CustomLog /var/www/domain.com/logs/access.log combined

SHOULD BE SPECIFIC TO YOUR VHOST:

# Logging
ErrorLog  /var/www/domain.com/logs/error-example.com.log
CustomLog /var/www/domain.com/logs/access-example.com.log combined

Upvotes: 1

Related Questions