Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

Thanks!

share|improve this question
add comment

migrated from stackoverflow.com Oct 1 '11 at 12:40

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 1 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
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
</Directory>

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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