If you want to make changes to the PHP directives of a single site this can usually easily be achieved by adding them to a .htaccess file. However, if you are running suPHP (a security tool which forces PHP scripts to be executed using the site owners permissions) directives added to a .htaccess file will be ignored.
This is because suPHP does not support the php_value/php_admin_value directives used to modify values in a .htaccess file. The way round this is to use a custom php.ini file and then reference this from your .htaccess file.
Let’s assume we have a site with home directory path /home/example and a document root of /home/example/public_html, we first need to copy the current into the document root (don’t worry, we will secure it later in the article), to form the basis of our custom copy.
cp /etc/php.ini /home/example/public_html/php.ini
Note: This assumes the path to php.ini is standard. If you’re not sure, run ‘php -i | grep php.ini’ to find the location of the currently loaded configuration file.
You can now edit this copy of the php.ini, and make the site specific changes required, using your preferred text editor, e.g.
vim /home/example/public_html/php.ini
Now we need to make sure the changes are picked up. Edit/create a .htaccess file:
vim /home/example/public_html/.htaccess
And add following directive to tell suPHP where to look for the custom php.ini file:
suPHP_ConfigPath /home/example/public_html
And make sure the php.ini isn’t publicly viewable by adding:
<Files php.ini>
order allow,deny
deny from all
</Files>
Restart apache and the site will then start using the values added to the custom php.ini file.