Php.ini not taking the local values.

You will need to create a file called php.cgi under the public_html directory of the user. The php.cgi must contain the following code in it.

#!/bin/sh
exec /usr/local/cpanel/cgi-sys/php5 -c /home/username/php.ini

Obviously, you will need to advise the client in your response that his custom php.ini file resides in /home/username/php.ini (if he puts a php.ini in the directory he needs the custom php config working in, this will not work).

The php.cgi must have execute permissions!

Once this is done, create a .htaccess in the directory you need custom php5 configuration working with the following code in it.

Options All -Indexes
AddHandler application/x-httpd-php5 .php
Action application/x-httpd-php5 /php5.cgi

Putting this code in other .htaccess files in other directories will make php5 use /home/username/php.ini as a configuration file too.

After that you can test it by putting a phpinfo() file in that directory and accessing it via browser. It should show the path to php.ini as /home/username/php.ini

Hope you enjoy it.

Leave a Reply