12

I have an Ubuntu 14.10 computer that is used for local website testing, it is not serving to the internet. On it, I have seven websites set up. However, when I access two of the seven, I get the Apache2 Ubuntu Default Page instead of my own index page.

As far as I can tell, I set up all seven using the exact same process, so I don't know what these two are missing. Also, in my Apache logs directory, I have two log files, error and access for each of the two misbehaving sites, but all of them are empty. When I restart the apache2 service, there are no errors. I have retraced my steps multiple times and I can not see any difference between the working sites and the non working sites.

What options do I have for diagnosing this problem? Can I force more verbose error logs somehow? Is there another log somewhere that I can reference?

Here is an example of a .conf file for one of the malfunctioning sites:

<VirtualHost *:80>
   ServerName www.local_example.com
   ServerAlias local_example.com
   ServerAdmin address@example.com

   DocumentRoot /var/www/Websites/example.com
   <Directory /var/www/Websites/example.com/>
       Options Indexes FollowSymLinks MultiViews
       # pcw AllowOverride None
       AllowOverride All
       Order allow,deny
       allow from all
       # This directive allows us to have apache2's default start page
       # in /apache2-default/, but still have / go to the right place
       # Commented out for Ubuntu
       #RedirectMatch ^/$ /apache2-default/
   </Directory>

   ErrorLog /home/example/Apache_Logs/local_example.com_error.log

   # Possible values include: debug, info, notice, warn, error, crit,
   # alert, emerg.
   LogLevel warn

   CustomLog /home/example/Apache_Logs/local_example.com_access.log combined
   ServerSignature On

</VirtualHost>
4
  • 2
    How did you create the virtual hosts? Did you create them by adding files to /etc/apache2/sites-available? If so, did you enable them with sudo a2ensite <your_site_name>? Does the default apache error log file have anything in it? And do you have a ServerAlias or ServerName configured in your virtual host files? If you disable the default site sudo a2dissite 000-default (you can re-enable it with sudo a2ensite 000-default), does it work? Also, it could be that you just forgot to restart apache?
    – Dan
    Mar 31 '15 at 7:44
  • @Dan, thank you for responding. I created the sites by adding them to sites-available. The default error log has nothing in it. I have defined ServerAlias in the hosts file. I disabled the 000-default site but that did not change anything. I restarted and reloaded apache many times.
    – Questioner
    Mar 31 '15 at 8:52
  • When you disabled the default site and restarted apache, it was still showing the default index.html page, or was it showing one from a different virtual host? Can you post the content of one of the misbehaving vhost files? This might make things much easier for us to help.
    – Dan
    Mar 31 '15 at 9:40
  • @Dan, Thank you for respondng. When I made the change you suggested, as I mentioned, nothing changed, meaning that it showed the exact same default index page. I've added a .conf file to my question.
    – Questioner
    Apr 1 '15 at 4:55
10

Try the following

Enable verbose logs

sudo nano /etc/apache2/apache2.conf

Locate the LogLevel variable, and update it from the default warn to info or debug. debug will produce the greatest amount of output.

# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
# 
LogLevel debug

Restart Apache

sudo service apache2 restart

Apache includes a nice little syntax checking tool

apache2ctl -t

Checking Virtual Host Definitions

apache2ctl -S
2
  • Thank you for this suggestion. I set the log level to debug, and I am still getting absolutely no entries in the error log files. The access logs now show every time I opened the sites, but nothing else.
    – Questioner
    Mar 31 '15 at 8:49
  • Thank you. You made my day.
    – sogu
    Dec 17 '20 at 16:46
8

For me, one of the suggestions from @Dan solved it.

sudo a2dissite 000-default.conf
service apache2 reload

Apparently the default site configuration was overriding my vhost configuration.

1
  • In other server it behaved differently and index.php was read instead of index.html. Very sneaky situation Feb 28 '18 at 20:36
4

after installation index.html has higher priority that's why you still seeing default Ubuntu page check this folder var/www/html/ rename or remove this page simple as that

3

Turns out the problem was permissions.

When you're storing the web site in a directory outside of /var/www and connected by symlink, then the source directory, and its parent directory have to have permissions of 755.

For some unknown reason, the two misbehaving sites had different permissions, and running chmod -R 755 on the web site directory, and its parent directory, solved the problem.

3
  • 1
    You should not run chmod -R 755 on a directory because all the files in there are going to be marked as "executable"... May 27 '16 at 5:44
  • @AlexisWilke, what is a better command for setting the right permissions?
    – Questioner
    May 27 '16 at 10:56
  • There isn't an easy one to change the permissions of all the directories and not the standard... You can use find though. Something like this: find top-dir-name -type d -exec chmod 755 {} \;. May 27 '16 at 16:57
1

I battled with the same issue.

I even deleted /var/www/html, did sudo a2dissite 000-default and deleted /etc/apache2/sites-available/000-default.conf and even then, the issue persisted.

In the end I figured out that the index.html was persisted due to some hardcoding in the c++ code.

The built in default DirectoryIndex is in /mods-available/dir.conf and goes like this:

DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm

My project had no index.html just an index.php

The solution was to add a DirectoryIndex to my vhost .conf in /etc/apache2/sites-available/ like this:

<Directory "/var/www/mysite">
   RewriteEngine On
   AllowOverride All
   Options Indexes FollowSymLinks MultiViews
   Require all granted
        
   #extra config to disable default index.html
   DirectoryIndex disabled
   DirectoryIndex index.php
</Directory>

This solved the issue completely for me.

1
  • Thanks for the info that it's probably hardcoded in C/C++ . For me I just added index.html in /var/www/html, it worked fine and showed some kind of new default behaviour (in the past defautl "index.html" was real not virtual) Aug 10 at 21:21

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