I have been asked several times at work by colleagues upgrading a Debian server why they get a page not found (404) error
on all their services hosted by Apache, without any error message and without having modified any configuration files.
Having encountered the same problem before, and after struggling for a bit before finding the obvious and simple solution, here is a quick summary.
Configuration changes
Apache 2.4 on Debian and Ubuntu now only reads files with the .conf
extension in the /etc/apache2/sites-enabled/
directory.
This is due to the new IncludeOptional
directive which does not fail if no files are found, unlike the previous Include
directive.
/etc/apache2/apache2.conf
now has:
# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf
Fix
Simply rename all the valid configuration files in /etc/apache2/sites-enabled/
to have the .conf
extension.
The best way to do that is to ensure that the configuration files in /etc/apache2/sites-available/
are all correct with a clean (empty) /etc/apache2/sites-enabled/
directory, and re-enable each configuration.
# Ensure that /etc/apache2/sites-enabled/ is empty
$ for i in /etc/apache2/sites-available/*
$ do
$ mv ${i} ${i}.conf
$ a2ensite ${i}
$ done
$ systemctl apache2 reload
More links
Excellent links on upgrading Apache 2.2 to Apache 2.4: