WordPress stops working after Ubuntu 20.04LTS upgrade to 22.04LTS

I just recently upgraded my blog from Ubuntu 20.04 LTS to 22.04 LTS and my main blog WordPress site would not load.

The php code was showing in the browser rather than being processed by php.

* Front to the WordPress application. This file doesn’t do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.

First, make sure that the libapache2-mod-php8.1 module is installed:

sudo apt install libapache2-mod-php8.1

Next browse to /etc/apache2/mods-enabled, and do an ls:

You will probably see two old php symlinks that don’t go anywhere anymore. If you look in the mods-available directory you will see they don’t exist.

We need to create two new symlinks for php8, do an ls in mods-available to make sure you see two php files

Create the symlinks in mods-enabled for the two in mods-available and restart apache2. This was done in the mods-enabled directory.

sudo service apache2 restart

If this works feel free to delete the old symlinks with just the “rm” command.

Happy Upgrading!