Ubuntu Tips: Apache does not execute PHP files

How to activate PHP for Apache per-user web directories on servers running Ubuntu 10.10.

23rd October 2010

Recently I setup Apache, MySQL and PHP with Apache per-user web directories after I completed a fresh installation of Ubuntu 10.10 Maverick meerkat. Once I completed the installation and tried running PHP scripts in my new public_html directory. The scripts however would not execute. This was really frustrating and took my a while to resolve this issues. So I have written this blog post to explain how to solve this problem and stop future frustrations.

Step 1 - Open the PHP config file

Start by opening the php5.conf. We need to modify this file so that it no longer prevents the execution of PHP scripts in users directories.

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

Step 2 - Tweaking the config file

Once you have open the php5.conf file start by finding the following line:

php_admin_value engine Off

Once you have found the line you now need to comment out the line so it no longer prevents PHP files from be executed in the per-user web directories. Do this by adding a hash character before 'php_admin_value'.

#php_admin_value engine Off

Once you have completed that change save the file and exit the editor.

Step 3 - Now restart the web server

Now you have quit your text editor and returned to you terminal command line execute the following command to restart Apache. Once that is complete you will now be able to run PHP files in per-user web directories.

sudo service apache2 restart

This work is licenced under a Creative Commons Licence.