# Fix Apache2 Modules Not Loading After System Upgrade
After running a system upgrade (apt upgrade or yum update), Apache refuses to start with errors like:
[Thu Apr 08 06:00:01.123456 2026] [so:error] [pid 1234] AH06665: No code signing authority for module at /usr/lib/apache2/modules/mod_php.sohttpd: Syntax error on line 56 of /etc/httpd/conf/httpd.conf: Cannot load modules/mod_ssl.so into server: /etc/httpd/modules/mod_ssl.so: cannot open shared object file: No such file or directoryAH00534: httpd: Configuration error: No MPM loaded.System upgrades can break Apache module loading in several ways.
Problem 1: Module Files Moved or Removed
After an upgrade, shared object files may have been relocated or replaced:
```bash # List loaded modules apache2ctl -M 2>&1 | head -30
# Check which modules Apache is trying to load grep -r "LoadModule" /etc/apache2/mods-enabled/ ```
If a module file is missing:
```bash # Find the module file find /usr/lib/apache2/modules/ -name "mod_*.so" | sort
# Check if the module package is installed dpkg -l | grep libapache2-mod- # or rpm -qa | grep httpd ```
Reinstall the missing module package:
```bash # Debian/Ubuntu sudo apt install --reinstall libapache2-mod-php8.2 sudo apt install --reinstall apache2-bin
# RHEL/CentOS sudo yum reinstall httpd httpd-tools mod_ssl ```
Problem 2: MPM Module Conflict
Apache can only use one MPM at a time. If an upgrade enables multiple MPMs:
apache2ctl -M 2>&1 | grep mpmIf you see multiple MPMs listed, disable all but one:
sudo a2dismod mpm_event
sudo a2dismod mpm_worker
sudo a2enmod mpm_prefork
sudo systemctl restart apache2Or for the event MPM (recommended for most use cases):
sudo a2dismod mpm_prefork
sudo a2dismod mpm_worker
sudo a2enmod mpm_event
sudo systemctl restart apache2Note: mod_php requires mpm_prefork. If you switch to mpm_event, you must use PHP-FPM instead.
Problem 3: PHP Module Incompatibility
After a PHP version upgrade, the old mod_php module no longer matches:
# Check PHP module version
ls -la /etc/apache2/mods-enabled/php*
# May show: php8.1.load -> ../mods-available/php8.1.load
# But system now has PHP 8.2Disable the old PHP module and enable the new one:
sudo a2dismod php8.1
sudo a2enmod php8.2
sudo systemctl restart apache2Problem 4: Configuration File Conflicts
System upgrades sometimes leave behind .dpkg-dist or .rpmnew configuration files that conflict with your existing configuration:
# Find distribution config files
find /etc/apache2/ -name "*.dpkg-dist" -o -name "*.dpkg-new"
find /etc/httpd/ -name "*.rpmnew" -o -name "*.rpmsave"Compare them with your current configuration:
diff /etc/apache2/apache2.conf /etc/apache2/apache2.conf.dpkg-distThe dist file may contain updated module paths or new default settings that your current config lacks.
Problem 5: Missing Dependencies
A module may fail to load because a shared library dependency is missing:
ldd /usr/lib/apache2/modules/mod_ssl.so | grep "not found"If any libraries show as "not found", install the missing packages:
```bash # Debian/Ubuntu sudo apt install libssl3
# RHEL/CentOS sudo yum install openssl ```
Full Recovery Procedure
If Apache is completely broken after an upgrade:
```bash # 1. Test configuration sudo apachectl configtest
# 2. Check which modules are enabled but not available for mod in /etc/apache2/mods-enabled/*.load; do modname=$(basename "$mod" .load) if ! apache2ctl -M 2>&1 | grep -q "$modname"; then echo "Module $modname is enabled but not loaded" fi done
# 3. Disable broken modules sudo a2dismod broken_module_name
# 4. Reinstall core packages sudo apt install --reinstall apache2 apache2-bin apache2-utils
# 5. Re-enable required modules sudo a2enmod rewrite ssl headers
# 6. Test and restart sudo apachectl configtest sudo systemctl restart apache2 ```
Prevention: Pin Critical Packages
To prevent unexpected breakages, pin the Apache and PHP packages:
```bash # Debian/Ubuntu sudo apt-mark hold apache2 apache2-bin libapache2-mod-php8.2
# Check held packages apt-mark showhold ```
This prevents automatic upgrades of Apache until you are ready to test and plan the migration.