Create Custom php.ini File in cPanel

Create custom php.ini
This article will help you create a custom php.ini file for a cPanel account when using CGI or FCGI as the PHP handler.

The following steps will help you create a custom php.ini file for a cPanel account when using CGI or FCGI as the PHP handler.

Enter to the cgi folder.

cd /home/user/public-html/cgi-bin

Copy the php.ini to that folder

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

Open the php.ini

vi php.ini

Change the PHP variable

For Example: register_globals = On

Create php.cgi (under the /home/user/public-html/cgi-bin folder) file to load custom php.ini, with the following content:

#!/bin/sh
/usr/local/cpanel/cgi-sys/php5 -c /home/user/public_html/cgi-bin/

Please note the path to php5 is due to using PHP5 on this system. If you are using php4, it might be /usr/local/cpanel/cgi-sys/php4 or some other path. Check /etc/httpd/conf/php.conf to see what it shows for the cgi-sys path for your version of PHP.
Save the file, then made executable:

chmod +x /home/user/public_html/cgi-bin/php.cgi

Change ownership of files to correct user:

chown -R user:user /home/user/public_html/cgi-bin/

Go to the document root and edit .htaccess to point to php.cgi wrapper

cd /home/user/public_html
vi .htaccess

Put the code given below at the top of the file:

Action application/x-httpd-php5 /cgi-bin/php.cgi

Again, here php5 is listed. If your PHP is different, use the Action listed for your version of PHP in /etc/httpd/conf/php.conf file.

So that’s how you create a custom php.ini file when the handler is CGI or FCGI in cPanel.

Share this post

Services to Explore

Stay up to date!

Stay up to date with the Web Hosting, Cloud and Server Management Industry News and Tutorials!

We will send you only the relevant emails, and we respect your privacy. Please review our privacy policy for more info.

cPanel & WHM Management Services

Focus on your business, and let us take care of your cPanel Servers!
From what you are reading, it seems you are interested in cPanel/WHM and related technologies. If you have a moment to spare, please take a look at our cPanel Management Services plan, and which might interest you even more!
cPanel Management Plan

Value-Added Services

We have services that can help you run a successful business. With us, you don't have to worry about these areas because our experts will take care of it for you.

Introducing - WPHealers!

Complete WordPress Management, 24x7 Support & White Label Agency Plans!

WordPress migration service, security, white-label reseller services and lot more! Grab the introductory deals now!

WPHealers

ServerHealers uses cookies.