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 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
1

3 Answers

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

This will disable the "Default" site, enable the "Default" site, and then the restart of Apache will refresh the configuration and should then use the updated docroot accordingly. Note there may be other permissions issues not discussed here; you would need to open a new question for that.

6

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. It's not my preferred solution, but it worked:

<VirtualHost webserver.mydomain.za:80> ServerAdmin 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 the first time.

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>

Reload apache.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like