PHP Code is not Executed by apache2 in Ubuntu
If you noticed that after installing apache2, server is behaving fine but it only serving you the static files means you php code is not executed by apache2.So in this article i am going to give you the solution of this problem.
Step 1 -> Install php library for apache2
First we need to install library module of php for apache2 so write the command given below in your terminal.
sudo apt-get install php libapache2-mod-php
Step 2-> Enable and disable some modules
Now we have to enable mpm_prefork and php module and disable mpm_event so for enabling and disabling we have command a2enmod stands for apache2enable module and a2dismod stands for apache2 disable module. So type the command given below in your terminal.
sudo a2dismod mpm_event && sudo a2enmod mpm_prefork && sudo a2enmod php7.0
if this command throws the error due to php version then check your php version by simply typing “php -v” and in place of php7.0 replace your php version.
Step->3 Restart apache2
Now everything is done just restart your apache2 server by typing below command and you are done.
sudo systemctl restart apache2