Walt Stoneburner's Ramblings

Currating Chaos

Enabling PHP on Home Directories

In the past, I've run php and allowed it within user subdirectories, thus content in public_html can use .php files.

All was going well until I upgraded the system, then all kinds of things broke relating to home pages.

Turns out there's a new policy with PHP that disables PHP by default in user home directories. This is actually a really good idea for security reasons.

However, if a system doesn't have untrusted users, it can be okay to re-enable.

This requires going into the /etc/apache2/mods-available/php*.conf file that contains the text public_html, and commenting out the IfModule statements.

1
2
3
4
5
#<IfModule mod_userdir.c>
# <Directory /home/*/public_html>
# php_admin_flag engine Off
# </Directory>
#</IfModule>

Do NOT set the content within them to On, as it may be so tempting to do; for doing so will prevent .htaccess from being able to override the setting.