Skip to main content

apache 2.2 - Multiple php versions simultaneously on Ubuntu

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:




  1. 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/

  2. 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.




  1. First I installed
    a default lamp stack using sudo apt-get install lamp-server^
    phpmyadmin
    . After this I had a working development server running the
    repository version of php.

  2. 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

  3. Then
    I enable suaxec and fastcgi for apache and disabe mod_php with sudo a2enmod
    fastcgi actions suexec && sudo a2dismod
    php5

  4. Next, I edited
    /etc/apache2/mods-enabled/fastcgi.conf to 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/



  5. 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-cgi

  6. The
    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





  7. Finally
    I changed /etc/hosts to
    read



    127.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

Popular posts from this blog

iLO 3 Firmware Update (HP Proliant DL380 G7)

The iLO web interface allows me to upload a .bin file ( Obtain the firmware image (.bin) file from the Online ROM Flash Component for HP Integrated Lights-Out. ) The iLO web interface redirects me to a page in the HP support website ( http://www.hp.com/go/iLO ) where I am supposed to find this .bin firmware, but no luck for me. The support website is a mess and very slow, badly categorized and generally unusable. Where can I find this .bin file? The only related link I am able to find asks me about my server operating system (what does this have to do with the iLO?!) and lets me download an .iso with no .bin file And also a related question: what is the latest iLO 3 version? (for Proliant DL380 G7, not sure if the iLO is tied to the server model)

linux - Awstats - outputting stats for merged Access_logs only producing stats for one server's log

I've been attempting this for two weeks and I've accessed countless number of sites on this issue and it seems there is something I'm not getting here and I'm at a lost. I manged to figure out how to merge logs from two servers together. (Taking care to only merge the matching domains together) The logs from the first server span from 15 Dec 2012 to 8 April 2014 The logs from the second server span from 2 Mar 2014 to 9 April 2014 I was able to successfully merge them using the logresolvemerge.pl script simply enermerating each log and > out_putting_it_to_file Looking at the two logs from each server the format seems exactly the same. The problem I'm having is producing the stats page for the logs. The command I've boiled it down to is /usr/share/awstats/tools/awstats_buildstaticpages.pl -configdir=/home/User/Documents/conf/ -config=example.com awstatsprog=/usr/share/awstats/wwwroot/cgi-bin/awstats.pl dir=/home/User/Documents/parced -month=all -year=all...

linux - How can I get my mediawiki to stop thinking I have cookies disabled?

I've searched half a day for how to resolve this issue, and can't figure it out. Shortly after I made my wiki a simple private wiki according to the instructions at Mediawiki's website, it started giving me this weird login error message: Wiki uses cookies to log in users. You have cookies disabled. Please enable them and try again. If I remove those private wiki settings, the error disappears, even if I try logging in. But I need it to be a private wiki for only my team. So what do I do? Here's what I've done so far. Just to be safe, after ever change, I try rebooting Apache using: sudo /etc/init.d/apache2 restart In my php.ini file, I have the following set: session.save_path = "/var/lib/php5" session.cookie_secure = secure session.cookie_path = /tmp session.cookie_domain = my server's internal URL (should I even set this? this field was blank before, but not commented out) session.referer_check = Off I ran the following to ensure that the fold...