PHP not interpreted, showing in view source

If you are using php7 make sure you installed this module.

sudo apt-get install libapache2-mod-php7.0

Replace 7.0 with the version of php you are using.

To find version of php, use

php -v 

You can install libapache2-mod-php5 using

apt-get install libapache2-mod-php5

Worked for me.


Are you sure you have php installed? If it is you need to make sure that apache is associating .php files with the php handler. Look for an entry similar to the following in /etc/apache/apache.conf

 LoadModule php5_module modules/libphp5.so

and

 application/x-httpd-php        php php5

upon changing the file you will need to restart apache via sudo service httpd restart

Tags:

Php

Apache