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:
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.
mkdir -p /var/cpanel/conf/apache/wrappers cp -frp /usr/local/cpanel/cgi-sys/php5 /var/cpanel/conf/apache/wrappers/php5
Step 4: Now restart Apache for the settings to become active:
service httpd restart
Step 5: In order to verify your settings have been applied you’ll want to create a PHP info script. Create a new file in the public_html folder called info.php and add the following code:
<?php // Show all information, defaults to INFO_ALL phpinfo(); ?>
Now when you visit your website and access the newly crated info.php script, you should see your custom php.ini being loaded next to the Loaded Configuration File section