Installing PHP 5.5.14 on Plesk 12 (Ubuntu 12.04)

Upgrading to a new version of PHP on a Plesk installation is not much of a hassle – Making sure all modules work properly is what makes it a tedious job. This article will guide you through how to do it on a Ubuntu 12.04 installation.

What we will achieve in this guide is how to install a new version of PHP with a lot of modules, including:

  • Opcache
  • Curl (with SSL support)
  • IMAP (with SSL support)
  • MCrypt
  • MySQL(i)
  • PDO

… and much more.

When we’re done, the new version will be an option in Plesk like so:

PHP 5.5.14 in Plesk

My setup is a Host Europe VPS clean install with the following setup

  • Ubuntu 12.04.4 LTS
  • Plesk 12.0.18 (Upgraded from 11 in Plesk Control Panel)

The actual guide

First off, SSH into your server, and you’ll be at the home folder of your current user. This guide assumes you are root, so if not:

sudo -s

Now, let’s get the dependencies we need to build PHP from source.

aptitude build-dep php5

apt-get install build-essential

apt-get install libxml2 libxml2-dev libssl-dev pkg-config curl libcurl4-gnutls-dev enchant libenchant-dev libjpeg8 libjpeg8-dev libpng12-0 libpng12-dev libvpx1 libvpx-dev libfreetype6 libfreetype6-dev libt1-5 libt1-dev libgmp10 libgmp-dev libicu48 libicu-dev mcrypt libmcrypt4 libmcrypt-dev libpspell-dev libedit2 libedit-dev libsnmp15 libsnmp-dev libxslt1.1 libxslt1-dev libbz2-dev libc-client2007e-dev

Next we should be make /usr/local/lib64 a symlink to /usr/local/lib, since PHP will search for some of the libraries in lib64

ln -s /usr/lib /usr/lib64

We should be ready to download, configure and compile PHP. Get the URL for the latest version here: http://php.net/downloads.php. I found this link for version 5.5.14: http://php.net/get/php-5.5.14.tar.bz2/from/this/mirror

Let’s download this file and unzip it

wget http://php.net/get/php-5.5.14.tar.bz2/from/this/mirror -O php.tar.bz2

tar -xvf php.tar.bz2

cd php-5.5.14/

Configuring and compiling PHP

This next line with configure PHP with all the modules I have found necessary. Feel free to modify it to your needs.

Please note that I have chosen to install it in /usr/local/php5514, if you would like to move it, remember to update all the references in the command below

./configure --disable-debug --disable-rpath --enable-bcmath --enable-calendar --enable-exif --enable-ftp --enable-fpm --enable-gd-native-ttf --enable-intl --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-pdo --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --enable-xmlreader --enable-xmlwriter --enable-zip --prefix=/usr/local/php5514 --with-bz2 --with-config-file-path=/usr/local/php5514/etc --with-config-file-scan-dir=/usr/local/php5514/php.d --with-curl --with-freetype-dir=/usr/local/php5514 --with-gd --with-gettext --with-gmp --with-iconv --with-imap --with-imap-ssl --with-jpeg-dir=/usr/local/php5514 --with-kerberos --with-libdir=lib64 --with-libxml-dir=/usr/local/php5514 --with-mcrypt --with-mysql --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pic --with-png-dir=/usr/local/php5514 --with-snmp --with-xmlrpc --with-xsl --with-zlib --without-gdbm

Now, we make and install it, this could take a while (really)

make

make install

When “make install” is complete, the PHP is installed in place, and we need to copy the php.ini file to the install directory

cp php.ini-production /usr/local/php5514/etc/php.ini

Adding a folder “php.d” which PHP will search for additional ini-files.

mkdir /usr/local/php5514/php.d

I have added the following to an ini-file in php.d, to enable OPCache and adjust some configuration files:

# /usr/local/php5514/php.d/custom.ini
date.timezone = Europe/Copenhagen
post_max_size = 32M
upload_max_filesize = 32M
zend_extension=/usr/local/php5514/lib/php/extensions/no-debug-non-zts-20121212/opcache.so
opcache.memory_consumption=64
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=2001
opcache.revalidate_freq=5
opcache.fast_shutdown=1
opcache.enable_cli=0
opcache.enable=1

Adding the PHP to Plesk

The final step is telling Plesk where to find our new PHP version. That is done with the following command (remember to adjust pathnames accordingly, if you have changed it)

/usr/local/psa/bin/php_handler --add -displayname 5.5.14 -path /usr/local/php5514/bin/php-cgi -phpini /usr/local/php5514/etc/php.ini -type fastcgi -id php5514

That’s it! Now Plesk knows where to find the updated PHP version, go ahead and log in to Plesk, and change the PHP handler in one of your domains hosting settings.

6 replies
  1. Justin Samuel
    Justin Samuel says:

    Thanks for this article. I used to be an admin for Plesk servers for many years. I got fed up, knew many others who were also fed up, and started a control panel company that does good stuff for PHP developers like make multiple versions of PHP available by default. It’s called ServerPilot.

    Of course, sometimes you don’t have a choice of what control panel to use. Or you might need stuff like email management which ServerPilot does do. In those cases, my condolences!

    Justin

    Svar
  2. Christian Waltemathe
    Christian Waltemathe says:

    Thanks for this article.
    Installation works fine, but my phpinfo file and some other scripts were not parsed by the new PHP-Version.
    After some time of googling I found in the php.ini that “short_open_tag” was configured as “Off”.

    Kind regards,
    Christian

    Svar
  3. Klaas
    Klaas says:

    Hi Martin,

    Thanks for this tutorial.

    Plesk (or Odin) is very clear about the fact that this works out of the box in Plesk 12.0 for several Linux distributions but not Ubuntu 12.04 LTS. It will be available for Ubuntu 14.04 LTS in Plesk 12.1, which is planned for release later this year.

    source:
    http://kb.odin.com/125146

    Note: Currently, PHP packages from the Plesk team are available on CentOS 6, CentOS 7, and Ubuntu 14. In Plesk 12.1, we are going to extend this list with Ubuntu 12, Debian 6, Debian 7, and RHEL 6, 7 operating systems.

    Did you really got this working without any problems on 12.04 LTS?

    Greetings,

    Klaas

    Svar
  4. Klaas
    Klaas says:

    I meant:
    It will be available for Ubuntu 12.04 LTS in Plesk 12.1, which is planned for release later this year.

    Svar
  5. Jesus Knox
    Jesus Knox says:

    Thank you very much for this piece of article, it’s great! I wore many hours trying to solve the problem of upgrade for php.

    a greeting

    Svar

Skriv en kommentar

Want to join the discussion?
Feel free to contribute!

Skriv et svar

Din e-mailadresse vil ikke blive publiceret. Krævede felter er markeret med *