PHP not interpreted on Apache server

2013-10-23 PHP

It may happen, that after successful installation of LAMP environment, when you will try to open PHP script in your browser, instead of result, you will see raw source code. It means that Apache is not handling PHP. To solve this open terminal and edit file:

sudo mcedit /etc/apache2/mods-enabled/php5.conf

It’s worth to backup this file before changing anything. Keep in mind also that your path to php5.conf can be different as well as editor you will use. Override the content of this file with:

<IfModule mod_php5.c>
  AddType application/x-httpd-php .php .phtml .php3 .php4
  AddType application/x-httpd-php-source .phps

Last step is to restart your Apache server.

sudo /etc/init.d/apache2 restart