Enable custom php.ini file for individual accounts in a cPanel based server with PHP CGI handler
Hello Guys,
Today I am going to let you know how to enable custom php.ini file for individual accounts in a cPanel based server. So, the first thing we should be doing is to find out the current working PHP handler in the server.
Step 1 : Login to the server as root user.
Step 2 : Execute the command;
It should give an output as below.
Available handlers: suphp dso cgi none
DEFAULT PHP: 5
PHP4 SAPI: none
PHP5 SAPI: suphp
SUEXEC: enabled
RUID2: not installed
Step 3: Now, navigate to the cgi-bin folder of the account for which custom php.ini is to be enabled
Step 4: Copy the default php.ini file from the server to this location
Step 5: Lets check if this custom php works without any problem by changing any PHP variable from the default to value to any custom value. Here I’m changing the value of memory_limit.
and enter the following code
Step 6: Now create php.cgi file to load custom php.ini. For that edit the file as below
and enter the following code into this file:
/usr/local/cpanel/cgi-sys/php5 -c /home/username/public_html/cgi-bin
Now the php.cgi file should look like as follows:
#!/bin/sh
/usr/local/cpanel/cgi-sys/php5 -c /home/user/public_html/cgi-bin/
Step 7: Now make the file executable by modifying its permissions as below.
Step 8: Correct the ownership of the files to the user
Step 8: Edit .htaccess to point to this php.cgi wrapper. To do that, put the following code into your .htaccess file in the public_html directory.
and enter the following
Now your .htaccess file will look like as follows:
Action application/x-httpd-php5 /cgi-bin/php.cgi
Step 9: Now you can check whether the custom php.ini file is working using a test php info page:
Put the following code in it:
Step 10: Correct the ownership of the file to the user:
Now you can test the phpinfo file by browsing it as domain.com/phpinfo.php. Now check the “Loaded configuration file” in the phpinfo page. It should be like “/home/username/public_html/cgi-bin/php.ini”.