Centos – Running single Apache Vhost on PHP 5.3 using CGI, other sites use PHP 5.2 on Apache module

apache-2.2centoscgiPHP

I've been trying to setup my development server to serve one of my Apache virtual hosts over CGI using PHP 5.3.14.

The Apache server I have setup is Apache 2.2.3 with PHP 5.2.10 running as an Apache module. CentOS 5.5 is the OS. One of the sites uses features only available in PHP 5.3, and I have sites that need 5.2, so I'd like to run only the site that need PHP 5.3 on over CGI.

I've followed a couple tutorials to the point where I have Apache/PHP 5.2 installed and working as a module. I also downloaded and compiled PHP 5.3.14 successfully to the point where I have the php-5.3.14/sapi/cgi/php-cgi executable built and ready to go. If I run it with a script it works correctly. However, after having added what I think are the correct directives to the VirtualHost, the site still is not using PHP 5.3, it continues to work, using PHP 5.2 (the version setup as an Apache module).

Here is my Vhost config:

<VirtualHost *:80>
 ServerName utfl.peapoddev.com
 ServerAlias elegal.utfl.peapoddev.com subsite.utfl.peapoddev.com library.utfl.peapoddev.com
 DocumentRoot /var/www/utfl/drupal
 DirectoryIndex index.html index.php

 SetEnv PHPRC /var/www/cgi-bin/php_5_3_14/
 ScriptAlias /php-5-3-14/ /var/www/cgi-bin/php_5_3_14/
 Action application/x-httpd-php-5-3-14 /php-5-3-14/php-cgi
 AddType application/x-httpd-php-5-3-14 .php .inc
 <Directory "/var/www/cgi-bin/php_5_3_14">
   <Files "php-cgi">
     Allow from all
   </Files>
 </Directory>

 <Directory "/var/www/utfl/drupal">
   Options Indexes Includes FollowSymLinks
   AllowOverride None
   Order allow,deny
   Allow from all
   AllowOverride All
 </Directory>

 LogLevel Debug
 ErrorLog /var/www/utfl/logs/error_log
 CustomLog /var/www/utfl/logs/access_log combined

Let me know if you need more info. What am I doing wrong?

Best Answer

I have been using the following configuration on CentOS-5.9

<VirtualHost *:80>
    ServerAdmin webmaster@example.net
    DocumentRoot /vhosts/php53.example.net/
    ServerName php53.example.net

    ScriptAlias /php-fastcgi/ /usr/local/php-5.3.26/bin/

    AddHandler php-fastcgi .php
    AddType application/x-httpd-php .php
    Action php-fastcgi /php-fastcgi/php-cgi

    <Directory /vhosts/php53.example.net/>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@example.net
    DocumentRoot /vhosts/php52.example.net/
    ServerName php52.example.net

    <Directory /vhosts/php52.example.net/>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

php-5.3 was configured with following options

# # ./configure --prefix=/usr/local/php-5.3.26/ --enable-force-cgi-redirect --enable-pcntl --with-imap=shared --with-imap-ssl --enable-mbstring=shared --enable-mbregex --with-gd=shared --enable-bcmath=shared --enable-dba=shared --with-db4=/usr --with-xmlrpc=shared --with-ldap=shared --with-ldap-sasl --with-mysql=shared,/usr --with-mysqli=shared --enable-dom=shared --with-pgsql=shared --enable-wddx=shared --with-snmp=shared,/usr --enable-soap=shared --with-xsl=shared,/usr --enable-xmlreader=shared --enable-xmlwriter=shared --with-curl=shared,/usr --enable-fastcgi --enable-pdo=shared --with-pdo-odbc=shared,unixODBC,/usr --with-pdo-mysql=shared --with-pdo-pgsql=shared,/usr --with-pdo-sqlite=shared,/usr --with-pdo-dblib=shared,/usr --enable-json=shared --enable-zip=shared --without-readline --with-libedit --with-pspell=shared --enable-phar=shared --with-mcrypt=shared,/usr --with-tidy=shared,/usr --with-mssql=shared,/usr --enable-sysvmsg=shared --enable-sysvshm=shared --enable-sysvsem=shared --enable-posix=shared --with-unixODBC=shared,/usr --enable-fileinfo=shared --enable-intl=shared --with-icu-dir=/usr --with-enchant=shared,/usr --with-libdir=lib64 --with-kerberos --with-sqlite=shared