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.

elloo,

i have some old php scripts which runs on php-5.2.x and the current server has php-5.3.x. to get around this problem,i have got two options one is to downgrade php-5.3.x or install php-5.2.x and php-5.3.x at the same time where php-5.2.x serve cgi script. i have decided go for the second option

i have followed this tutorial and i can get most of it working however except execution of shell script which selects php-cgi version. i cannot get apache to execute this script.

how do i get apache to execute

#!/bin/sh
# you can change the PHP version here.
version="5.2.6"
# php.ini file location, */php-5.2.6/lib equals */php-5.2.6/lib/php.ini.
PHPRC=/etc/php/phpfarm/inst/php-${version}/lib/php.ini
export PHPRC

PHP_FCGI_CHILDREN=3
export PHP_FCGI_CHILDREN

PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS

# which php-cgi binary to execute
exec /etc/php/phpfarm/inst/php-${version}/bin/php-cgi

my apache vhost.conf

<VirtualHost *:80>
    ServerName 526.localhost
    DocumentRoot /home/getmizanur/public_html/www
    <Directory "/home/getmizanur/public_html/www">
        AddHandler php-cgi .php
        Action php-cgi /php-fcgi/php-cgi-5.2.6
    </Directory>
</VirtualHost>

can some one tell me what am i doing wrong?

thanks in advance.

solution: if i did a2dismod php5 then the above configuration worked. when a2enmod php5 had been activated, apache was executing php5.3 instead of php5.2 even after telling apache to execute php5.2 shell script. to solve my problem, i had to change my virtualhost configuration

<VirtualHost *:80>
    ServerName 526.localhost
    DocumentRoot /home/getmizanur/public_html/www

    DirectoryIndex index.php
    <Directory "/home/getmizanur/public_html/www">
        AddHandler php-cgi .php
        Action php-cgi /php-fcgi/php-cgi-5.2.6

        <FilesMatch "\.php">
            SetHandler php-cgi
        </FilesMatch>
    </Directory>
</VirtualHost>

presto, it started working.

share|improve this question
    
Anything in the errorlog? Check permissions on the script, and make sure none of the directories in the path are inaccessible to the user Apache is running as. –  Andy Smith Dec 19 '10 at 21:45
    
you should add your solution as an actual answer so I can upvote it –  Jeff Atwood Jan 16 '11 at 6:23
    
Did you already got it working? If not.. let me know, there are a few things you should check :D –  dbforch Jan 16 '11 at 6:23
    
getmizanur: please post your solution as answer and accept it, not as edit in your question. –  cweiske Aug 11 '11 at 10:57

1 Answer 1

Depending on your particular requirements - in specific, whether you can live with executing PHP as a CGI rather than through mod_php - suPHP (http://www.suphp.org/Home.html) can be a very handy tool for this. You can use it to create a profile for various CGI interpreters, including multiple versions of PHP, and execute requests through a given interpreter based on factors including the extension of the file, environment variables set in an .htaccess file on the path, etc.

I use it to allow developers to specify in their .htaccess files which version of PHP they want to execute, so I can support legacy PHP 4, current stable 5, and testing of newer releases, all in the same web server infrastructure, with the added bonus of getting PHP execution out of the hands of the web server user and back into the context of the file owner. Hope this helps.

share|improve this answer

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.