Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have looked all over and found ways to compile PHP as a cgi/secondary install but no guides show how to compile PHP 5.4 as a cgi to be called in a .htaccess. I want to have a development cgi version of future updates so that I can test my code and make sure it will be supported in future versions.

Has anyone seen any articles I may have missed or be able to explain how to create a cgi version of PHP on a CentOS 5.6 box with cPanel?



migration rejected from Feb 22 at 15:40

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as off-topic by HopelessN00b, Ward, Jenny D, kasperd, RobM Feb 22 at 15:40

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 0 down vote accepted

The answer I found was to use suhosin or suphp. First I had to compile PHP and drop it into a directory that was not the original cPanel install of it:

./configure --prefix=/opt/phpdev --disable-fileinfo --disable-phar --enable-bcmath --enable-calendar --enable-ftp --enable-gd-native-ttf --enable-libxml --enable-mbstring --enable-pdo=shared --enable-sockets --enable-zip --with-bz2 --with-curl=/opt/curlssl/ --with-curlwrappers --with-freetype-dir=/usr --with-gd --with-gettext --with-imap=/opt/php_with_imap_client/ --with-imap-ssl=/usr --with-jpeg-dir=/usr --with-kerberos --with-libxml-dir=/opt/xml2/ --with-mcrypt=/opt/libmcrypt/ --with-mysql=/usr --with-mysql-sock=/var/lib/mysql/mysql.sock --with-mysqli=/usr/bin/mysql_config --with-openssl=/usr --with-openssl-dir=/usr --with-pcre-regex=/opt/pcre --with-pdo-mysql=shared --with-pdo-sqlite=shared --with-png-dir=/usr --with-xpm-dir=/usr --with-xsl=/opt/xslt/ --with-zlib --with-zlib-dir=/usr --with-config-file-path=/opt/phpdev

make test
make install

Secondly I needed to edit the /opt/suphp/etc/suphp.conf and add application/x-httpd-phpdev="php:/opt/phpdev/bin/php-cgi" after [handlers] ;Handler for php-scripts:

In the /usr/local/apache/conf/includes/pre_main_global.conf file I placed:

AddType application/x-httpd-phpdev .phpdev
<Directory />
suPHP_AddHandler application/x-httpd-phpdev

Finally I added AddType application/x-httpd-phpdev .php to the .htaccess file in the directory I wanted to add


Not the answer you're looking for? Browse other questions tagged or ask your own question.