Installer PHP 5.6 sous Plesk Obsidian (Ubuntu 18)

Lecture de 2 minutes

Basé sur le commentaire de Robert ici : https://support.plesk.com/hc/en-us/articles/115000497853/comments/360000717999.

UPDATE: Je crois que l'article précédent a été remplacé par celui-ci.

Télécharger et installer les dépendances

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install libxml2-dev libssl-dev php-dev libtool-bin php5.6 libbz2-dev libenchant-dev libxpm-dev libjpeg-turbo8-dev libpng-dev libfreetype6-dev libgmp-dev libsqlite3-dev libedit-dev libreadline-dev libtidy-dev libxslt-dev

Créer les symlinks manquant

sudo ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h 

Télécharger la source PHP 5.6.40

wget https://www.php.net/distributions/php-5.6.40.tar.gz
gunzip php-5.6.40.tar.gz 
tar -xf php-5.6.40.tar php-5.6.40/
cd php-5.6.40/

Configurer

./configure --prefix=/opt/plesk/php/5.6.40 --bindir=/opt/plesk/php/5.6.40/bin --sbindir=/opt/plesk/php/5.6.40/sbin --libexecdir=/opt/plesk/php/5.6.40/lib --datadir=/opt/plesk/php/5.6.40/share --sysconfdir=/opt/plesk/php/5.6.40/etc --sharedstatedir=/opt/plesk/php/5.6.40/com --localstatedir=/opt/plesk/php/5.6.40/var --libdir=/opt/plesk/php/5.6.40/lib/x86_64-linux-gnu --includedir=/opt/plesk/php/5.6.40/include --infodir=/opt/plesk/php/5.6.40/share/info --mandir=/opt/plesk/php/5.6.40/share/man --with-libdir=lib --cache-file=../config.cache --with-config-file-path=/opt/plesk/php/5.6.40/etc --with-config-file-scan-dir=/opt/plesk/php/5.6.40/etc/php.d --enable-mysqlnd=shared --with-mysql=shared,mysqlnd --with-mysqli=shared,mysqlnd --with-mysql-sock=/var/run/mysqld/mysqld.sock --enable-dom=shared --enable-soap=shared --enable-xmlreader=shared --enable-xmlwriter=shared --enable-json=shared --enable-zip=shared --without-readline --with-mcrypt=shared,/usr --build=x86_64-linux-gnu --host=x86_64-linux-gnu --disable-debug --without-pear --with-pic --disable-rpath --with-bz2 --with-freetype-dir=/usr --with-png-dir=/usr --with-xpm-dir=/usr --enable-gd-native-ttf --without-gdbm --with-gettext --with-gmp --with-iconv --with-jpeg-dir=/usr --with-openssl --with-zlib --with-layout=GNU --enable-exif --enable-ftp --enable-sockets --enable-sysvsem --enable-sysvshm --enable-sysvmsg --with-kerberos --enable-calendar --with-libxml-dir=/usr --enable-xml --enable-phpdbg --with-enchant=shared,/usr --with-litespeed --enable-pcntl --enable-mbstring=shared --enable-mbregex --with-gd=shared --enable-bcmath=shared --enable-dba=shared --with-xmlrpc=shared --enable-soap=shared --with-xsl=shared,/usr  --with-curl=shared,/usr --enable-pdo=shared --with-pdo-mysql=shared,mysqlnd --with-pdo-sqlite=shared,/usr --with-sqlite3=shared --with-libedit --enable-phar=shared --with-tidy=shared,/usr --enable-fileinfo=shared --enable-intl=shared --with-icu-dir=/usr --enable-sysvmsg=shared --enable-sysvshm=shared --enable-sysvsem=shared --enable-posix=shared build_alias=x86_64-linux-gnu host_alias=x86_64-linux-gnu

À partir de là, nous obtenons un correctif pour faire fonctionner la version 5.6 avec openssl 1.1.

wget http://zettasystem.com/PHP-5.6.31-OpenSSL-1.1.0-compatibility-20170801.patch
patch -p1 < PHP-5.6.31-OpenSSL-1.1.0-compatibility-20170801.patch

Créer et installer avec OpenSSL patché

make
sudo make install

Copier PHP.ini au dossier de Plesk

sudo mkdir -p /opt/plesk/php/5.6.40/etc/php.d
sudo cp php.ini-production /opt/plesk/php/5.6.40/etc/php.ini

Configurer l'extension MySQL

cd ./ext/mysql
phpize
./configure --with-php-config=/opt/plesk/php/5.6.40/bin/php-config
make
sudo make install

Ajouter les extensions to PHP.ini

printf "zend_extension=opcache.so\nextension=mysqlnd.so\nextension=bcmath.so\nextension=curl.so\nextension=dba.so\nextension=dom.so\nextension=enchant.so\nextension=fileinfo.so\nextension=gd.so\nextension=imap.so\nextension=intl.so\nextension=json.so\nextension=mbstring.so\nextension=mcrypt.so\nextension=mysql.so\nextension=mysqli.so\nextension=odbc.so\nextension=pdo.so\nextension=pdo_mysql.so\nextension=pdo_odbc.so\nextension=pdo_sqlite.so\nextension=phar.so\nextension=posix.so\nextension=soap.so\nextension=sqlite3.so\nextension=sysvmsg.so\nextension=sysvsem.so\nextension=sysvshm.so\nextnsion=tidy.so\nextension=xmlreader.so\nextension=xmlrpc.so\nextension=xmlwriter.so\nextension=xsl.so\nextension=zip.so\n" | sudo tee -a /opt/plesk/php/5.6.40/etc/php.ini > /dev/null

Register le handler dans Plesk

sudo /usr/local/psa/bin/php_handler --add -displayname 5.6.40 -path /opt/plesk/php/5.6.40/bin/php-cgi -phpini /opt/plesk/php/5.6.40/etc/php.ini -type fastcgi -id 5.6.40 -clipath /opt/plesk/php/5.6.40/bin/php

FACULTATIF - Pour supprimer (désinstaller) le gestionnaire de Plesk

sudo /usr/local/psa/bin/php_handler --remove -id 5.6.40