How to enable multiple PHP versions in Plesk for Linux


2016-11-16 12:44:50 UTC


2017-08-16 17:13:26 UTC


Was this article helpful?

Have more questions?

Submit a request

How to enable multiple PHP versions in Plesk for Linux

Applicable to:

  • Plesk 12.5 for Linux
  • Plesk 11.x for Linux
  • Plesk 12.0 for Linux
  • Plesk 12.5 for Windows


How to enable multiple PHP versions in Plesk for Linux


On Linux systems, you can install any PHP version you need and then make it available in Plesk by registering it with php_handler command-line utility.

For CloudLinux :

If you are a CloudLinux user, you can use the CloudLinux PHP selector feature:

For Plesk 12 and Plesk 12.5:

Since Plesk 12.0.18 MU#41 , you can install and use multiple PHP 5.x versions built by the Plesk team via the Plesk. For more details, see Multiple PHP Versions in Plesk 12 and higher Out of the Box

PHP packages for Plesk 12:

  • CentOS 6
  • CentOS 7
  • Ubuntu 12

PHP packages for Plesk 12.5:

  • CentOS 6
  • CentOS 7
  • RHEL 6
  • RHEL 7
  • Debian 7
  • Debian 8
  • Ubuntu 12
  • Ubuntu 14

Step 1. Install required PHP version on your Plesk server

For installation guidelines, refer to the official PHP documentation available at .

    Note: It is recommended to build PHP in another (non-production) environment with the same operating system version as on the target server. This helps you avoid installing a large number of unnecessary packages on your production system. In the example below, PHP 5.6.3 is used. However you can use the instructions to install any PHP version.

The installation includes the following main steps:

  1. Download PHP source:

    # cd /usr/local/src/
    # wget --output-document="php-5.6.3.tar.bz2"
  2. Make sure that PHP distribution package has been downloaded successfully:

    # ls -la
    total 13156
    drwxr-xr-x 2 root root 4096 Nov 29 08:39 .
    drwxr-xr-x 15 root root 4096 Nov 29 08:39 ..
    -rw-r--r-- 1 root root 13461539 Nov 14 06:41 php-5.6.3.tar.bz2
  3. Unpack it from the archive:

    # tar xjvf php-5.6.3.tar.bz2
    # mv php-5.6.3 php563
  4. Install necessary libraries:

    On CentOS 6:

    # yum install libxml2-devel openssl-devel bzip2-devel curl-devel libjpeg-devel libpng-devel freetype-devel gmp-devel mysql-devel ncurses-devel unixODBC-devel net-snmp-devel mhash-devel libc-client-devel libicu-devel gcc postgresql-devel aspell-devel libxslt-devel gcc-c++ openldap-devel

    On Debian 6 Squeeze:

    # apt-get install libxml2-dev libbz2-dev libcurl4-openssl-dev libjpeg-dev libpng-dev libfreetype6-dev libgmp3-dev libc-client-dev libicu-dev libsasl2-dev unixodbc-dev libpspell-dev libsnmp-dev libxslt-dev
  5. Install additional libraries: this depends on the system that is used for the PHP compilation. It will become clear on the configure step.

  6. Configure:

    # cd /usr/local/src/php563
    # ./configure '--with-libdir=lib64' '--cache-file=../config.cache' '--prefix=/usr/local/php563-cgi' '--with-config-file-path=/usr/local/php563-cgi/etc' '--disable-debug' '--with-pic' '--disable-rpath' '--with-bz2' '--with-curl' '--with-freetype-dir=/usr/local/php563-cgi' '--with-png-dir=/usr/local/php563-cgi' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr/local/php563-cgi' '--with-openssl' '--with-pspell' '--with-pcre-regex' '--with-zlib' '--enable-exif' '--enable-ftp' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-wddx' '--with-kerberos' '--with-unixODBC=/usr' '--enable-shmop' '--enable-calendar' '--without-sqlite3' '--with-libxml-dir=/usr/local/php563-cgi' '--enable-pcntl' '--with-imap' '--with-imap-ssl' '--enable-mbstring' '--enable-mbregex' '--with-gd' '--enable-bcmath' '--with-xmlrpc' '--with-ldap' '--with-ldap-sasl' '--with-mysql=/usr' '--with-mysqli' '--with-snmp' '--enable-soap' '--with-xsl' '--enable-xmlreader' '--enable-xmlwriter' '--enable-pdo' '--with-pdo-mysql' '--with-pdo-pgsql' '--with-pear=/usr/local/php563-cgi/pear' '--enable-intl' '--without-pdo-sqlite' '--with-config-file-scan-dir=/usr/local/php563-cgi/php.d' '--enable-cgi'
    • Note: It is required to use a switch prefix for new PHP to be installed inside a single directory. As an example, the prefix here is /usr/local/php563-cgi/
    • Choosing a prefix is important as it prevents new PHP installation from interfering with other PHP installations available on the server.
  7. Compile PHP:

    # cd /usr/local/src/php563
    # make
  8. [Skip this step if PHP has been built in a production environment] Archive compiled PHP and transfer it to your Plesk server.

    Please note that the full path to the directory containing the compiled PHP on the Plesk server must be the same as on the source server:

    # cd /usr/local/src/
    # tar cjvf php563.tar.bz2 php563
    # scp php563.tar.bz2 root@<your_plesk_server_ip>:/usr/local/src
  9. Connect by SSH to your Plesk server and unpack the archive file with the compiled PHP:

    # cd /usr/local/src
    # tar xjvf php563.tar.bz2
  10. Go to your Plesk server and install PHP:

    # cd /usr/local/src/php563
    # make install
  11. Set up php.ini :

    # cp php.ini-development /usr/local/php563-cgi/etc/php.ini
    • You can edit the php.ini file to set PHP options. If you prefer having ' php.ini ' in another location, run the configure utility with the option --with-config-file-path=/some/path in configure step.
  12. Restore SELinux contexts:

    # restorecon -R /usr/local/php563-cgi

Step 2. Register new PHP version in Plesk

# /usr/local/psa/bin/php_handler --add -displayname <NN> -path <path to php cgi> -clipath <path to php-cli> -phpini <path to php.ini> -type <php handler> -id <NN-custom>


  • displayname <NN> is the PHP version name that will be shown in the Plesk interface. We recommend you to include the version number in the displayname. For example, you could name the version "5.6.3-custom".

  • path <path/to/php/cgi> is the location of the PHP CGI binary file. You can find this in the output of the "make install"command in the "Installing PHP CGI binary" line. For example, if you see the following in the "Installing PHP CGI binary" line: /usr/local/php563-cgi/bin/ , the location you need to specify is /usr/local/php563-cgi/bin/php-cgi . Learn more at the Official PHP web Site .

  • clipath <path to php-cli> is the location of the php file, for example, /usr/local/php563-cgi/bin/php

  • phpini <path/to/php.ini> is the location of the php.ini file, for example, /usr/local/php563-cgi/etc/php.ini .

  • -type <php handler> is the type of PHP handler associated with this version. It can be either 'cgi' or 'fastcgi'.

  • -id <NN-custom> is the identifier you will use when referring to this PHP version (for example, when adjusting or removing it).

For example:

# /usr/local/psa/bin/php_handler --add -displayname php-5.6.3 -path /usr/local/php563-cgi/bin/php-cgi -clipath /usr/local/php563-cgi/bin/php -phpini /usr/local/php563-cgi/etc/php.ini -type fastcgi -id 2

After you register the PHP version in Plesk, it will be available for selection in the Websites > Hosting Settings of a particular website. See the picture below:

Listing Registered PHP Handlers:

To see a list of registered PHP handlers on a Plesk server, run this command:

# /usr/local/psa/bin/php_handler --list
Have more questions? Submit a request
Please sign in to leave a comment.