Project

General

Profile

Install php53 to php52 in parallel » History » Revision 33

Revision 32 (Andreas Kohlbecker, 05/09/2012 11:53 AM) → Revision 33/40 (Andreas Kohlbecker, 05/09/2012 11:55 AM)

 

 ## Installing php5.3 and php5.2 in parallel 


 _Running multiple versions of PHP at the same time is required if you are about running Druapl 5 and Druapl 6 or 7 together on the same server. 

 The following guide describes how to install php5.2 manually in parallel to php5.3, which includes compiling and installing php 5.2 from source.The instructions will work with the following    Debian Linux versions and derived distributions: Debian sqeeze 6.0.4, Ubuntu Precise Pangolin 11.10, Ubuntu Precise Pangolin 12.04, on.  

 For similar instructions on installing    php5.3 and php5.2 in parallel in older distributions please refer to [[Install_php53_to_php52_in_parallel_ubuntu-1110|Install php5.3 to php5.2 in parallel in ubuntu-11.10]]._ 



 see also:  

 * http://bernhardhaeussner.de/blog/89_Howto:_PHP5.3_parallel_zu_PHP5_installieren 

 * http://artur.ejsmont.org/blog/content/compiling-and-building-php-53-on-ubuntu 





 ### 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 dpkg-dev libcurl4-gnutls-dev gawk libgd2-xpm-dev libgd2-xpm libmhash-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 symbolic links symlinks exist in @/usr/lib@, if nor create them!: 


 Ubuntu and Debian: 

 ~~~ 
 ln -s /usr/include/gd.h /usr/lib/gd.h 
 ~~~ 


 Ubuntu only: 

 ~~~ 
 # 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 

 1. extract 

 1. 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](http://anonscm.debian.org/gitweb/?p=pkg-php/php.git;a=blob_plain;f=debian/rules;hb=41ffb985b80d560777d6c9f9264d129cc6d386ee) 


 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.   

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

 ~~~