Enable PHP in Userdirs

This post was migrated from my Techblog.

In my Apache post, I mentioned that it was a nasty process enabling php in per-user directories. Well, I did another google search today, and it turns out I was wrong — it’s actually very easy!

All you have to do is open the /etc/apache2/mods-enabled/php5.conf file and comment out this bit of code:

<IfModule mod_userdir.c>
    <Directory /home/*/public_html>
        php_admin_value engine Off
    </Directory>
</IfModule>

Remember, comments in Apache begin with #. Also, just in case you were tempted, the file warns against changing the Off to On, as that would prevent any .htaccess files from disabling the engine.

Now, restart Apache and you should be good to go:

$ sudo /etc/init.d/apache2 restart

Many thanks to this article, where I found this information!