Apache Configuration file 000-default.conf not working

https://askubuntu.com/questions/861021/apache-configuration-file-000-default-conf-not-working

So I'm trying to change the DocumentRoot of my apache, but for some strange reason it just seems to ignore the file /etc/apache2/sites-available/00-default.conf

This is the content of the file:

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin webroot@localhost
    DocumentRoot /home/david/www


    <Directory /home/david/www>
        Options Indexes
            Require all granted
    </Directory>
    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

add a comment

3 Answers

ActiveOldestVotes4

Apache ignores sites-available until you enable the site (in which case it symlinks it in sites-enabled).

Run the following commands:

sudo a2dissite 000-default
sudo a2ensite 000-default
sudo systemctl restart apache2
  • $#sudo a2ensite 000-default Site 000-default already enabled seems like it is already enabled. Didn't work – David Dec 15 '16 at 19:08

  • @David If it says that then run the restart command. If it's still not working, then disable the site, enable the site, and restart Apache. – Thomas Ward♦ Dec 15 '16 at 19:10

  • Still did not work. All commands execute just fine, but it doesn't seem to have any effect – David Dec 15 '16 at 19:15

  • 1Use joao.machado-family.com/2013/06/04/…Panther Dec 15 '16 at 19:23

add a comment0

Try removing.

<Directory /home/david/www>
    Options Indexes
        Require all granted
</Directory>

Example:

VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /home/david/www>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

None of the above solutions worked for me. No matter what I tried I could not get the default site to load including copying the config from my 14.04 VPS where it is working 100% (I am upgrading to 18.04).

In the end adding a VirtualHost for the local server name to my apache2.conf forcing it to be the first VirtualHost defined worked. Not my preferred solution but worked:

<VirtualHost webserver.mydomain.za:80> ServerAdmin webmaster@mydomain.za ServerName webserver.mydomain.za DocumentRoot /var/www/nowebsite ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>

Strangely enough, the Default SSL site worked first time.

Last updated