You can follow the instructions below to set a custom php.ini file per user when using FastCGI with cPanel on your server.

Step 1 – Make a backup copy of your cPanel PHP wrapper script:

cp -frp /usr/local/cpanel/cgi-sys/php5 /usr/local/cpanel/cgi-sys/php5.bk

Step 2 – Edit the cPanel PHP wrapper script:

vimĀ /usr/local/cpanel/cgi-sys/php5

Add the following line aboveĀ exec /usr/bin/php:

[[ -f ~/public_html/php.ini ]] && exec /usr/bin/php -c ~/public_html/php.ini

The file should now look like:

#!/bin/sh

# If you customize the contents of this wrapper script, place
# a copy at /var/cpanel/conf/apache/wrappers/php5
# so that it will be reinstalled when Apache is updated or the
# PHP handler configuration is changed

[[ -f ~/public_html/php.ini ]] && exec /usr/bin/php -c ~/public_html/php.ini
exec /usr/bin/php

Step 3 – Now you will want to copy the PHP wrapper script to a more permanent location. This will ensure the settings are saved if you ever recompile Apache.

Continue reading