The following steps will allow a custom php.ini file on an account when using FCGI as the PHP handler.

Copy and Edit default php.ini

Code:

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

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

vi php.ini

As a test change one of the variables like register_globals from:

Code:

register_globals = Off

To:

Code:

register_globals = On

If yours was On, then do the reverse. This is simply to test it changes from the global php.ini file.

Create php.fcgi file to load custom php.ini

Code:

vi php.fcgi

Please note that you should still be in /home/user/public_html/cgi-bin location.

Put into file:

Code:

#!/bin/sh

export PHP_FCGI_CHILDREN=1

export PHP_FCGI_MAX_REQUESTS=10

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

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 cgi-sys path for your version of PHP.

Save file, then made executable:

Code:

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

Change ownership of files to correct user:

Code:

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

Edit .htaccess to point to php.fcgi wrapper

Code:

cd /home/user/public_html

vi .htaccess

Put at top of file:

Code:

AddHandler php5-fastcgi .php

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

Again, here php5 is listed.

Add paths to php.conf file

Add the following lines to /usr/local/apache/conf/php.conf file:

Code:

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

AddType application/x-httpd-php .php

Yours will probably look similar to the following after those lines are added:

Code:

# Fastcgi configuration for PHP5

LoadModule fcgid_module modules/mod_fcgid.so

MaxRequestsPerProcess 500

AddHandler fcgid-script .php5 .php4 .php .php3 .php2 .phtml

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

AddType application/x-httpd-php .php

FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php5

FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php4

FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php

FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php3

FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php2

FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .phtml

Distill and rebuild Apache, then restart Apache

Run these commands:

Code:

/usr/local/cpanel/bin/apache_conf_distiller –update

/scripts/rebuildhttpdconf

/etc/init.d/httpd restart

Load phpinfo page on account

Code:

cd /home/user/public_html

vi php.php

In file put:

Code:

<?php

phpinfo();

?>

Change ownership to the user:

Code:

chown user:user php.php

Load the file at http://domain.com/php.php to see the results.

Your phpinfo file should now show register_globals changed as well as have this at the top defining the new php.ini path:

Code:

Loaded Configuration File /home/user/public_html/cgi-bin/php.ini

—–
PHP CGI Individual php.ini File

The following steps will allow a custom php.ini file on an account when using CGI as the PHP handler.

Copy and Edit default php.ini

Code:

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

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

vi php.ini

As a test change one of the variables like register_globals from:

Code:

register_globals = Off

To:

Code:

register_globals = On

If yours was On, then do the reverse. This is simply to test it changes from the global php.ini file.

Create php.cgi file to load custom php.ini

Code:

vi php.cgi

Please note that you should still be in /home/user/public_html/cgi-bin location.

Put into file:

Code:

#!/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 cgi-sys path for your version of PHP.

Save file, then made executable:

Code:

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

Change ownership of files to correct user:

Code:

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

Edit .htaccess to point to php.cgi wrapper

Code:

cd /home/user/public_html

vi .htaccess

Put at top of file:

Code:

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.

Load phpinfo page on account

Code:

cd /home/admin/public_html

vi php.php

In file put:

Code:

<?php

phpinfo();

?>

Change ownership to the user:

Code:

chown user:user php.php

Load the file at http://domain.com/php.php to see the results.

Your phpinfo file should now show register_globals changed as well as have this at the top defining the new php.ini path:

Code:

Loaded Configuration File /home/user/public_html/cgi-bin/php.ini