I want to be able to run multiple php versions on my
development box running Ubuntu 12.04. What I want to accomplish is that when I use
localhost as domain a default is used (let's say php 5.3.17). When I use 547.localhost
as domain php 5.4.7 is used. I've seen some tutorials to get this working using fastcgi
but until now I haven't been able to get it to work.
I've looked at these
tutorials:
- href="http://dbforch.wordpress.com/2010/05/21/apache2-fastcgi-multiple-php-versions-ubuntulucid-10-04/"
rel="nofollow
noreferrer">http://dbforch.wordpress.com/2010/05/21/apache2-fastcgi-multiple-php-versions-ubuntulucid-10-04/ - href="http://www.metod.si/multiple-php-versions-with-apache-2-fastcgi-phpfarm-on-ubuntu/"
rel="nofollow
noreferrer">http://www.metod.si/multiple-php-versions-with-apache-2-fastcgi-phpfarm-on-ubuntu/
For
as far as I can see I have done everything that is needed. The problem is that php
simply doesn't run. When I go to
http://localhost/somephpfile.php it just outputs the source of
the php file. The same for
http://547.localhost/somephpfile.php.
I'll break down what steps I took in
the hope that someone is able to spot what I
missed.
- First I installed
a default lamp stack usingsudo apt-get install lamp-server^. After this I had a working development server running the
phpmyadmin
repository version of php. - Then I used phpfarm to create
two php installs, one for 5.3.17 and one for 5.4.7. The localion of phpfarm is
/etc/php/phpfarm, so the executables are in
/etc/php/phpfarm/inst/php-{version}/bin - Then
I enable suaxec and fastcgi for apache and disabe mod_php withsudo a2enmod
fastcgi actions suexec && sudo a2dismod
php5 Next, I edited
/etc/apache2/mods-enabled/fastcgi.confto read:
FastCgiIpcDir /var/lib/apache2/fastcgi
FastCgiWrapper
/usr/lib/apache2/suexec FastCgiConfig -idle-timeout
110 -killInterval 120
-pass-header HTTP_AUTHORIZATION -autoUpdate
ScriptAlias /php-fcgi/
/var/www/cgi-bin/
Then
in/var/www/I created a folder cgi-bin and in this folder two
files, for each of the two php versions as follows (I show only the one for 5.3.17
/var/www/php5317.fcgi):#!/bin/sh
#
you can change the PHP version here.
version="5.3.17"
#
php.ini file location, */php-5.2.13/lib equals
*/php-5.2.13/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-cgiThe
last step was to create virtual hosts. In the end I have three files in
/etc/apache2/sites-enabled: 000-default, php5.3.17 and php5.4.7
With the following
contents:default:
*:80>
ServerName localhost
DocumentRoot
/var/www
Options Indexes
FollowSymLinks MultiViews
AllowOverride All
Order
allow,deny
allow from all
AddHandler php-cgi .php
Action php-cgi /php-fcgi/php5317.fcgi
php5.3.17:
*:80>
ServerName 5317.localhost
DocumentRoot
/var/www
Options Indexes
FollowSymLinks MultiViews
AllowOverride All
Order
allow,deny
allow from all
AddHandler php-cgi .php
Action php-cgi /php-fcgi/php5317.fcgi
php5.4.7:
*:80>
ServerName 547.localhost
DocumentRoot /var/www
Options Indexes FollowSymLinks
MultiViews
AllowOverride All
Order allow,deny
allow
from all
AddHandler php-cgi .php
Action php-cgi
/php-fcgi/php547.fcgi
Finally
I changed /etc/hosts to
read127.0.0.1
localhost
127.0.0.1 547.localhost
127.0.0.1
5317.localhost
# The following lines are desirable for IPv6 capable
hosts
::1 ip6-localhost ip6-loopback
fe00::0
ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1
ip6-allnodes
ff02::2
ip6-allrouters
Now
I would expect things to work, but sadly they don't. Instead that a php files runs
through php it just outputs the raw
file.
There must be something I
missed here, but I have gone through the process many times and I can't figure out where
it goes wrong.
Comments
Post a Comment