How to fix Linux Apache not executing php files

Use the following code on Terminal to fix Apache not executing php files in Linux

sudo a2dismod mpm_event
sudo a2enmod mpm_prefork
sudo a2enmod php8.1
Depending on your configuration, you may also need to use:
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php8.1-fpm

Then Reload Apache2 

systemctl reload apache2

Reference: