default apache index.html shows up even though i have a sites-enabled file
I have installed apache2, there is a config file in /etc/apache2/sites-available and sites-enabled has a soft link to it. on the server, however, i still see /var/www/html/index.html. I have tried restarting apache with no luck. If I stop apache, nothing shows up on the box, so I'm certain it's not a multiple dameon issue or something like that. Can anyone think of any reason why apache is not seeing the enabled site?
In /etc/apache2/apache2.con, I have
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf
But other than that, I don't see why apache would be hard wired to show the default index.
Thanks for any help, Kevin
UPDATE
here is the site config file:
<VirtualHost *:80>
ServerName example.com
DocumentRoot "/var/www/sites/example.com/current/public"
ErrorLog "/var/log/apache2/example.com-error_log"
CustomLog "/var/log/apache2/example.com-access_log" common
<Directory "/var/www/sites/example.com/current/public">
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>
RewriteEngine On
# Remove the www
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/ [R=301,L]
</VirtualHost>
UPDATE
As an experiment, I removed the closing ">" to the config file to make it not well-formed, restarted apache and got no errors. This tells me the sites-enabled configs are not even being parsed.
Only accessing the site as http://example.com will trigger the host you have configured. Going to http://www.example.com , the server's IP, or any other method will fall back to Apache default.
Edit: For clarification, you can do one of the following:
- If you want this as your default/only host, then don't even bother with VirtualHost tags, and apply your configuration at the server level
- Add a Server Alias line like
ServerAlias example.com *.example.com
- Add a new VirtualHost for www.example.com and define the redirect there
The Debian version of Apache 2.4 specifically loads *.conf in the apache2.conf:
IncludeOptional sites-enabled/*.conf
It turns out my config file didn't end in .conf so it was never being loaded. Renaming it from example.com to example.conf fixed the problem.