Using a custom php.ini when using FAST CGI (fcgi) in Cpanel WHM

When using FastCGI (FCGI) as the loader for PHP, traditional php_values in the .htaccess file as well as custom php.ini files in the public_html directory no longer work. Instead we must create a wrapper for the main FCGI binary that causes the php.ini to be loaded from it’s current working directory instead of the server-wide one.

Edit the .htaccess file in the directory you want to use a custom PHP configuration for and add the following lines to the bottom of the file:

AddHandler php5-fastcgi .php
Action php5-fastcgi /cgi-bin/php5.fcgi

Next, you’ll need to copy your your main server php.ini which is located in /usr/local/lib/. Also note that it needs to have the correct ownership.

cd /home/user/public_html/cgi-bin/
cp -a /usr/local/lib/php.ini .
chown user:user php.ini
chgrp user:user php.ini

Create a file in your current directory (cgi-bin) called  php5.fcgi as defined above and add the following:

#!/bin/sh
export PHP_FCGI_CHILDREN=1
export PHP_FCGI_MAX_REQUESTS=10
exec /usr/local/cpanel/cgi-sys/php5

Finally, make sure the ownership and permissions are correct on this file:

chown user:user php5.fcgi && chmod 0755 php5.fcgi
chgrp user:user php5.fcgi && chmod 0755 php5.fcgi

You can now edit the php.ini inside cgi-bin/ and change the desired values. You can verify they are set properly by inserting the phpinfo() function inside a PHPscript on that user account.


5Pin Automotive Car Relay Switch SPDT Harness Socket Waterproof 40A DC 12V 12AWG picture

5Pin Automotive Car Relay Switch SPDT Harness Socket Waterproof 40A DC 12V 12AWG

$10.75



20PCS ROCKER SWITCH Toggle 12V Led Light Car Auto Boat Round ON/OFF SPST 20 AMP picture

20PCS ROCKER SWITCH Toggle 12V Led Light Car Auto Boat Round ON/OFF SPST 20 AMP

$7.89



Toggle SWITCH ON/OFF Heavy Duty 15A 125V SPST 2 Terminal Car Boat Waterproof ORG picture

Toggle SWITCH ON/OFF Heavy Duty 15A 125V SPST 2 Terminal Car Boat Waterproof ORG

$4.49



4 Pack SPST Normally Open Momentary Push Button Switch Red picture

4 Pack SPST Normally Open Momentary Push Button Switch Red

$4.95



Toggle SWITCH ON/OFF/ON Heavy Duty 20A 125V SPDT 3 Terminal Car Waterproof BOOT picture

Toggle SWITCH ON/OFF/ON Heavy Duty 20A 125V SPDT 3 Terminal Car Waterproof BOOT

$4.99



Air Compressor Pressure Switch Control 95-125 PSI H/D Pressure switch w/Unloader picture

Air Compressor Pressure Switch Control 95-125 PSI H/D Pressure switch w/Unloader

$13.99



16mm 12V LED ON OFF Push Button Power Switch Latching with Wire Socket Harness picture

16mm 12V LED ON OFF Push Button Power Switch Latching with Wire Socket Harness

$7.88



19mm Water Proof Starter Switch Boat Horn Momentary Push Button Stainless Steel picture

19mm Water Proof Starter Switch Boat Horn Momentary Push Button Stainless Steel

$5.25



10PCS SPST Mini Toggle Switch Wires On/Off Metal Small Automotive/Boat/Car/Truck picture

10PCS SPST Mini Toggle Switch Wires On/Off Metal Small Automotive/Boat/Car/Truck

$13.98



6Pack 12V 30A Fuse Relay Switch Harness Set SPST 5Pin 14 AWG Hot Wires US picture

6Pack 12V 30A Fuse Relay Switch Harness Set SPST 5Pin 14 AWG Hot Wires US

$16.19



Powered by WordPress. Designed by WooThemes