Custom php.ini for PHP CGI in cPanel.

February 26, 2010 | In: Cpanel, PHP

Hi guys,

When PHP is compiled as CGI, you won’t be able to provide custom php flags in .htaccess or just simply add a php.ini if your home directory.

To enable a custom php.ini for your domain running PHP as cgi, perform the following steps.

Please note that I am considering that the server has PHP4 and PHP5 where PHP4 is default (dso)-not relevant and PHP5 (cgi)

My username is “presoon” so my home directory will be “/home/presoon” (replace with yours)

create a custom cgi script in your cgi-bin directory.

vi /home/presoon/public_html/cgi-bin/php.cgi

add the following contents.

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

You should have the custom php.ini at “/home/presoon/public_html/”

chown presoon.presoon /home/presoon/public_html/cgi-bin/php.cgi
chmod 755 /home/presoon/public_html/cgi-bin/php.cgi

Now to the .htaccess file at “/home/presoon/public_html/”
Add the following

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

Please note that AddHandler given above is to change default php to PHP5. If you have only PHP5 which is compiled as CGI, you can remove the directive AddHandler from .htaccess.

Now the values given in your php.ini at /home/presoon/public_html/ should reflect you info page. 🙂

mm
Hi All… I have been working the IT Industry since last ten years… Specialized in Linux, Cloud Infrastructure and Solution Design.
On the hobby friend, I do research on IOT, Micro-controllers, Electronics etc.
Music is my passion..Connect me on..

Comment Form

*

Authors

mm
Presoon John

Hi All... I have been working the IT Industry since last ten years... Specialized in Linux, Cloud Infrastructure and Solution Design.
On the hobby friend, I do research on IOT, Micro-controllers, Electronics etc.
Music is my passion..Connect me on..

Access this post via Mobile

Scan the QR Code
QR Code Generator

Categories