Apache issues when upgrading from 20.04LTS >> 22.04LTS

Been a while since I posted! I recently began an upgrade project for my Linux virtual machines which ranged from 14.04 to 17.04. The goal was to get everything on 22.04LTS. One of the issues I ran into (3 times so far) is with Apache not working:

apache2: Syntax error on line 146 of /etc/apache2/apache2.conf: Syntax error on line 3 of /etc/apache2/mods-enabled/php7.4.load: Cannot load /usr/lib/apache2/modules/libphp7.4.so

After some google searching, I came across the below fix which hopefully helps others too:

#Disable old php 7.4
sudo a2dismod php7.4

#Enable php 8.1 
sudo a2enmod php8.1

#Bounce Apache
systemctl restart apache2

This has worked on three systems so far all moving from 20.04 LTS to 22.04 LTS. Hopefully someone else finds this helpful!

Leave a Reply