A reference guide to the most common Apache errors and their direct fixes, including Apache's distinctive "AH" (Apache HTTP) error codes.
500 Internal Server Error
Usually caused by a broken .htaccess file, a PHP fatal error, or incorrect file permissions.
sudo tail -f /var/log/apache2/error.log
Test if the issue is .htaccess by temporarily renaming it:
mv .htaccess .htaccess.bak
403 Forbidden
sudo chown -R www-data:www-data /var/www/yoursite
sudo chmod -R 755 /var/www/yoursite
Also verify the <Directory> block includes:
Require all granted
AH00558: Could Not Reliably Determine the Server's Fully Qualified Domain Name
Harmless startup warning — set a global ServerName to silence it:
sudo nano /etc/apache2/apache2.conf
ServerName localhost
AH00013: Pre-configuration Failed / Syntax Error
Always validate before restarting:
sudo apache2ctl configtest
This reports the exact file and line number of the syntax error.
AH00526: Invalid Command (Module Not Loaded)
A directive from a module that isn't enabled. Enable it:
sudo a2enmod MODULE_NAME
sudo systemctl restart apache2
Port 80 Already in Use
sudo ss -tulpn | grep :80
Usually another web server (Nginx) is already bound to the port.
.htaccess Rules Not Working
Confirm AllowOverride All is set in the site's <Directory> block and that mod_rewrite is enabled:
sudo a2enmod rewrite
sudo systemctl restart apache2
PHP Files Download Instead of Executing
sudo apt install libapache2-mod-php -y
sudo a2enmod php8.3
sudo systemctl restart apache2
Adjust the PHP version to match what's installed.
Diagnostic Checklist
sudo apache2ctl configtest— validate config syntax firstsudo systemctl status apache2— confirm the service is actually runningsudo tail -f /var/log/apache2/error.log— the fastest path to the real cause- Check file/directory ownership and permissions for 403/500 errors
Related Articles
- How to Install Apache on Ubuntu & Debian
- Apache Virtual Hosts: Hosting Multiple Websites
- How to Install Let's Encrypt SSL with Certbot (Nginx & Apache)
