02/15/2020
How-to install PHP 5.6 under Plesk Obsidian (Ubuntu 18)
2 minutes read
Based on Robert's comment here: [https://support.plesk.com/hc/en-us/articles/115000497853/comments/360000717999](https://support.plesk.com/hc/en-us/ articles/115000497853/comments/360000717999).
UPDATE: I believe the previous article has been replaced by [this one](https://support.plesk.com/hc/en-us/articles/12377508651415--How-to-add- a- custom-PHP-version-in-Plesk-for-Linux).
Download and install dependencies
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
Create missing symlinks
sudo ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h
Download PHP 5.6.40 source
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/
Configure
./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
From here we get patch to make 5.6 work with 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
Make and install with patched OpenSSL
make
sudo make install
Copy PHP.ini to Plesk folder
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
Configure MySQL extension
cd ./ext/mysql
phpize
./configure --with-php-config=/opt/plesk/php/5.6.40/bin/php-config
make
sudo make install
Add 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\nextension=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 handler to 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
OPTIONAL - To remove (uninstall) handler from Plesk
sudo /usr/local/psa/bin/php_handler --remove -id 5.6.40