Project

General

Profile

Actions

Install php53 to php52 in parallel » History » Revision 27

« Previous | Revision 27/40 (diff) | Next »
Andreas Kohlbecker, 05/04/2012 11:25 AM


How to install php5.3 to php5.2 in parallel

This instructions are specific to Debian Linux and derivatives like Ubuntu from version 12.04 on. For install php5.3 to php5.2 in parallel in older distributions please refer to Install php5.3 to php5.2 in parallel in ubuntu-11.10.

In the following you will find a brief description on how to compile and install php 5.2 from source.

see also:

Install additional packages

apt-get install bison re2c libmysqlclient-dev libbz2-dev bzip2 libxslt1.1 libxslt1-dev libxml2 libxml2-dev libjpeg62-dev libpng12-dev libxpm-dev

You may need more package if you are not having apache2, mysql, gcc and linux sources.

Check symlinks in /usr/lib (Ubuntu only, not needed for Debian?)

Check if the below symlinks exist in @/usr/lib@, if nor create them!:

# cd /usr/lib
# ln -s x86_64-linux-gnu/libjpeg.a libjpeg.a
# ln -s x86_64-linux-gnu/libjpeg.so libjpeg.so
# ln -s x86_64-linux-gnu/libpng.a libpng.a
# ln -s x86_64-linux-gnu/libpng.so libpng.so
# ln -s x86_64-linux-gnu/libXpm.so libXpm.so
# ln -s x86_64-linux-gnu/libgd.a libgd.a
# ln -s /usr/include/gd.h gd.h
# ln -s /usr/lib/x86_64-linux-gnu/libmysqlclient.so /usr/lib/

see also https://github.com/vladgh/VladGh.com-LEMP/blob/master/install_files/php.sh

Download and extract php 5.2 source

  1. download http://php.net/downloads.php

  2. extract

  3. cd into the extracted folder

Run the configure command

_This configuration is based on based on pkg-php/php.git/debian/rules":http://anonscm.debian.org/gitweb/?p=pkg-php/php.git;a=blob_plain;f=debian/rules;hb=HEAD._ The php5.2 rules are found "here

Run the configure command below inside the extracted php source folder.

dpkg-architecture -qDEB_HOST_GNU_TYPE

./configure is reporting errors:

  1. I you are getting an error like configure: error: xxxx not found. Please check your XXXX installation. Check if you have installed the xxx package and also the according development package.

  2. You can debug your the configuration by searching for the line of code in ./configure wich is producing the error message and add the following code snipped before the lines found:

###DEBUG
set -x

Execute the configure command again an see the detailed output.

Build and install

make
# optional, dauert, findet aber Fehler:
make test
# bringt die Dateien an ihren Platz: 
sudo make install | tee php52-install.log

Configure Apache

This was the tricky part!

Now please follow the instruction on: http://bernhardhaeussner.de/blog/89_Howto:_PHP5.3_parallel_zu_PHP5_installieren

The instruction on this page are on manually installing php 5.3, so you have to replace all occurrences of "php53" by "php52" in order translate it to our case.

Since the original blog post is no longer available I am copying the relevant paragraphs to here:


original blog post from Bernhard Häussner - http://bernhardhaeussner.de/blog/89_Howto:_PHP5.3_parallel_zu_PHP5_installieren

Jetzt muss noch Apache über das neue CGI-Modul informiert werden. Dazu müssen die folgenden Konfigurationen gesetzt werden (z.B. elegant in einer neuen Datei /etc/apache2/conf.d/php53cgi.conf):

# Damit mod_mime die neue Dateierweiterung erkennt:
AddHandler php53-cgi .php53
# Damit die Binaries aufgerufen, nicht versendet, werden:
ScriptAlias /bin-php53 /usr/bin/php53/
# Was eigentlich passieren soll:
Action php53-cgi /bin-php53/php-cgi
# Und noch ein paar Einstellungen für die Binaries:
<Directory /usr/bin/php53>
    # Kein .htaccess:
    AllowOverride None
    # CGI aktivieren, softlinks folgen
    Options +ExecCGI +FollowSymLinks
    # normalerweise ist der Zugriff auf alle „sonstigen“ Dateien gesperrt, 
    # daher hier wieder freigeben: 
    Order allow,deny
    Allow from all
</Directory>

Zum Testen kann man z.B. eine phpinfo.php53-Datei anlegen und man sollte die neue PHP-Verion angezeigt bekommen. Auf dieser Info-Seite kann man dann prüfen, ob alle Module verwendbar sind, die Zeitzone gesetzt ist und anderen potentielle Konfigurationsfehler auf die Schliche kommen. PHP 5.3 wird auch seine eigene php.ini in /etc/php53/apache2/php.ini verwenden, wohin man vielleicht zunächst die alte Konfigurationsdatei kopieren will.

# php.ini replazieren:
sudo cp /etc/php5/apache2/php.ini /etc/php53/apache2/php.ini
# im Webroot phpinfo mit namespace-Spielerei anlegen :)
echo "<?php namespace YEEES; phpinfo();" > phpinfo.php53

Nach den Schritten dieses Tutorials dürfte dann PHP 5.3 mehr oder weniger optimal laufen, ohne dass die Funktion alter Scripte eingeschränkt werden muss, und es lässt sich einfach die Interkompatibilität zwischen den Versionen testen.


Virtual Host and directory configuration

=

In your virtual host configuration file, put a SetHandler directive in the according Directory directive. E.g:

#
# Drupal 5 to run with php5.2
#
<Directory /var/www/drupal5>
    # run Drupal 5 with php5.2 which has been installed manually
    # see also http://dev.e-taxonomy.eu/trac/wiki/Install_php5.3_to_php5.2_in_parallel
    #

    <FilesMatch "\.php">
        SetHandler php52-cgi
    </FilesMatch>
    Options FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

Updated by Andreas Kohlbecker about 12 years ago · 27 revisions