The Server
I have a development server that I'm using to host my current projects. Here are some stats:
root@myserver:/usr/bin $ cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.10
DISTRIB_CODENAME=maverick
DISTRIB_DESCRIPTION="Ubuntu 10.10"
root@myserver:/usr/bin $ apache2 -v
Server version: Apache/2.2.16 (Ubuntu)
Server built: Nov 18 2010 21:17:43
root@myserver:/usr/bin $ php --version
PHP 5.3.3-1ubuntu9.1 with Suhosin-Patch (cli) (built: Oct 15 2010 14:00:18)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
root@myserver:/usr/bin $ uname -r
2.6.35-22-server
The Problem
I'm running PHP 5.3.3 using mod_php5
and it's working great. But I need to run PHP 5.2.11 for just one VH on the server, so I used phpfarm to compile PHP 5.2.11. I want to configure Apache to use mod_php5 for everything on the server except for this VH. I'll run PHP 5.2.11 for this one VH over FastCGI.
My Test
As a test, I'm using Apache's default site at /var/www
. I set up the following directory files to report PHP versions to me:
- /var/www/phpinfo.php
- /var/www/php-5.2.11/phpinfo.php
My objective is to have /var/www/phpinfo.php
show me version 5.3.3 (mod_php5) and have /var/www/php-5.2.11/phpinfo.php
show me 5.2.11 (CGI). This isn't working yet.
I inserted the following code /etc/apache2/httpd.conf
:
FastCgiServer /var/www/cgi-bin/php-cgi-5.2.11
ScriptAlias /cgi-bin-php/ /var/www/cgi-bin/
I inserted the following code into the default site's VH definition:
<Directory /var/www/php-5.2.11/>
AddHandler php-cgi .php
Action php-cgi /cgi-bin-php/php-cgi-5.2.11
</Directory>
Results
With mod_php5
enabled:
- /var/www/phpinfo.php ---> 5.3.3 (
mod_php5
) - /var/www/php-5.2.11/phpinfo.php ---> 5.3.3 (
mod_php5
)
With mod_php5
disabled:
- /var/www/phpinfo.php ---> no handler; Firefox tries to download the PHP file
- /var/www/php-5.2.11/phpinfo.php ---> 5.2.11 (CGI)
The Files Involved
mod_php
if at all possible. Were you going to suggest that I just set a default CGI handler and shutoffmod_php
for good? – Expresssu_php
which is 1) flexible, as you can install a gazillion handlers and 2) is more secure. – Whisenant