How to add custom php.ini for servers running FastCGI

Most of our servers run PHP as CGI module (needed for suPHP).



The Server API will be listed as “CGI”.

In these servers you can create a custom php.ini inside your public_html and the domains will load this configuration instead of the global php.ini

Our few servers have PHP as FastCGI. Setting a custom php.ini for this PHP handler will need a few settings to be done at the customer’s end.

In these servers the Server API will be listed as CGI/FastCGI.


Below are the steps to enable custom php.ini for FastCGI PHP handler:

Open .htaccess of the user and add the below codes:

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

Move to the cgi-bin folder of the account

cp /usr/local/lib/php.ini /home/user/public_html/cgi-bin/

Note: (contact us to copy the global php.ini to your cgi-bin or you can create an empty php.ini file)

chmod 755 /home/user/public_html/cgi-bin/php.ini

cd /home/user/public_html/cgi-bin/

vi php5.fcgi (insert the below codes and save)

exec /usr/local/cpanel/cgi-sys/php5

Save and quit the file

chmod 755 /home/user/public_html/cgi-bin/php5.fcgi

Posted under cPanel/Linux Hosting, PHP.ini | RSS 2.0

One Comment on How to add custom php.ini for servers running FastCGI

  1. Abner says:

    For PHP 5.3, you should replace all instance of php5 with php53

    eg: exec /usr/local/cpanel/cgi-sys/php5 with exec /usr/local/cpanel/cgi-sys/php53

    AddHandler php5-fastcgi .php with AddHandler php53-fastcgi .php and so on

Leave a Reply

Your email address will not be published. Required fields are marked *