After upgrading Ubuntu, many users encounter this puzzling error where Apache complains about a missing httpd.conf
file - a file that was never part of the default Debian/Ubuntu Apache installation in the first place. Let's dive into why this happens and how to fix it.
Ubuntu/Debian's Apache packaging uses a modular configuration system that's different from the traditional httpd.conf
approach. Your directory listing shows the standard structure:
conf.d/
mods-available/
mods-enabled/
sites-available/
sites-enabled/
apache2.conf
envvars
ports.conf
The key players here are apache2.conf
(main config) and the Include
directives that pull in other files.
During upgrades, sometimes old configuration directives get carried forward. Check line 215 of your apache2.conf
(as indicated in the error) - you'll likely find something like:
# OBSOLETE: Remove this after upgrade
Include /etc/apache2/httpd.conf
This line needs to be removed or commented out.
Modern Ubuntu Apache configurations should use the following include structure instead:
# These are the correct includes for Debian/Ubuntu
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
After making changes, always verify your configuration:
sudo apache2ctl configtest
sudo systemctl restart apache2
Check the status with:
systemctl status apache2.service
If you have legacy configurations that need preservation, you can:
sudo touch /etc/apache2/httpd.conf
sudo chmod 644 /etc/apache2/httpd.conf
Then move your custom configurations into this file.
Remember that Ubuntu uses sites-available
and sites-enabled
for virtual hosts. Example virtual host:
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/html
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Enable it with:
sudo a2ensite example.com.conf
Always check logs when troubleshooting:
sudo tail -f /var/log/apache2/error.log
This often reveals more specific issues than the generic configtest failure.
After an Ubuntu upgrade, many Apache users encounter this configuration error because the package maintainers have changed the default configuration structure. Modern Ubuntu versions use a modular approach where configurations are split across multiple files in /etc/apache2
.
# Typical modern Apache2 directory structure:
/etc/apache2/
├── apache2.conf # Main configuration
├── conf-available/ # Available configuration snippets
├── conf-enabled/ # Enabled configuration snippets
├── mods-available/ # Available modules
├── mods-enabled/ # Enabled modules
├── sites-available/ # Available site configurations
├── sites-enabled/ # Enabled site configurations
├── ports.conf # Ports configuration
└── envvars # Environment variables
The error occurs because your apache2.conf
still contains this legacy line:
# This is line 215 causing the error
Include /etc/apache2/httpd.conf
Modern Ubuntu versions no longer use httpd.conf
as the primary configuration file. The functionality has been distributed across various files in the new structure.
Option 1: Remove the obsolete include (recommended)
sudo sed -i '/Include \/etc\/apache2\/httpd.conf/d' /etc/apache2/apache2.conf
sudo systemctl restart apache2
Option 2: Create an empty httpd.conf file (temporary fix)
sudo touch /etc/apache2/httpd.conf
sudo systemctl restart apache2
After making changes, always test your configuration:
sudo apache2ctl configtest
# Expected output: Syntax OK
sudo systemctl status apache2
# Should show active (running)
For the modern Apache2 structure on Ubuntu:
- Place virtual host configurations in
/etc/apache2/sites-available/
- Enable them with
a2ensite
command - Add module configurations in
/etc/apache2/mods-available/
- Use
a2enmod
to enable modules
If problems persist, check these logs:
# View error log in real-time
sudo tail -f /var/log/apache2/error.log
# Check for failed services
sudo systemctl --failed
Remember that after major Ubuntu upgrades, it's often necessary to review and update configuration files as default locations and structures may change.