- Plesk for Linux
How to add a custom PHP version in Plesk for Linux?
Warning: All the instructions below are to be performed at own will and risk. These steps are provided for demonstration purposes only and not supported by Plesk. Depending on the operating system and the desired configuration, installation steps might differ significantly. When installing an additional PHP version on the server, read the official PHP documentation on installation. It's recommended to perform the installation on a test environment before modifying the production environment.
On Linux systems, you can install any PHP version you need and then make it available in Plesk by registering it with the
plesk bin php_handler command-line utility.
Click on a section to expand
Install the desired PHP version on the server. For installation guidelines, refer to the official PHP documentation available at http://php.net/manual/en/install.php. In brief, the installation includes the following main steps.
Connect to the server via SSH
Install C compiler and XML library with the following commands:
RHEL based OSes:
# yum install gcc -y && yum install libxml2-devel -y
Debian based OSes:
# apt-get install build-essential && apt-get install libxml2-dev
Download the PHP source you need from the official website (http://php.net/downloads.php or http://php.net/releases/) to the server and unpack it:
# gunzip php-NN.tar.gz
# tar -xf php-NN.tar
Configure and build PHP:
Note: In this step, it's possible to customize PHP with various options, such as specifying which extensions will be enabled in the compiled PHP version. Run
./configure --helpto see a list of the available options.
# cd ../php-NN
# ./configure --prefix /usr/local/phpNN --enable-fpm --with-fpm-group=www-data
# make install
Set up the
Note: Edit the
.inifile to set the desired PHP options. If it's required to configure the
php.inifile in another location, run the
configureutility with the option
--with-config-file-path=/some/pathin the previous step.
# cp php.ini-development /usr/local/lib/php.ini
Connect to the server via SSH
Register the new PHP version in Plesk:
Note: More information can be found with the following command:
plesk bin php_handler --help
2.1- CGI/FastCGI example:
# plesk bin php_handler --add -displayname <NN> -path <path to php-cgi binary> -phpini <path to php.ini> -type <php handler> -id <NN-custom> -clipath <path to php cli>
-displayname<NN>: It's the PHP version name that will be shown in the Plesk UI. It's recommended to include the version number in the
displayname, for example:
-path<path to php-cgi binary>: It's the location of the PHP CGI binary file. The location is shown in the output shown by the command
make installin the line Installing PHP CGI binary. For example, if the output contains the line Installing PHP CGI binary: /usr/local/bin/, the location to specify is /usr/local/bin/php-cgi. Learn more at: http://php.net/manual/en/install.unix.commandline.php
-clipath<path to php cli>: It's the location of the PHP CLI binary file. The location is shown in the output of the command
make installin the line Installing PHP CLI binary. For example, if the output contains the line Installing PHP CLI binary: /usr/local/bin/, the location to specify is /usr/local/bin/php. Learn more at: http://php.net/manual/en/install.unix.commandline.php
-phpini<path to php.ini>: It's the location of the
php.inifile, for example:
-type<php handler>: It's the type of the PHP handler associated with the installed PHP version. This example is for cgi , fpm or fastcgi PHP handlers and the mod_php is not supported
-id<NN-custom>: It's the identifier that will be used for referring to this PHP version when adjusting or removing it via
plesk bin php_handlersutility
2.2- FPM example (Notes: systemctl unit should also be created manually, if it specific for OS distribution; To add the PHP handler as a dedicated application, append '-fpm-dedicated' to the hander ID when registering; To add PHP as a 'usual' FPM application, add the handler second time, without the '-fpm-dedicated' ):
# plesk bin php_handler --add -displayname <NN> -path <path to php-fpm binary> -phpini <path to php.ini> -type fpm -id <NN-custom> -clipath <path to php cli> -service <PHP FPM service name> -poold <path to php-fpm.d pool folder>
-path<path to php-fpm binary>: It's the location of the PHP FPM binary file. The location is shown in the output shown by the command
make installin the line Installing PHP-FPM binary
-service<PHP FPM service name>: It's the PHP FPM service name
-poold<path to php-fpm.d pool folder>: It's the location containing the pool configuration files
Once the custom PHP versions are registered after applying the steps above, the custom PHP versions will be available:
Assign the custom PHP version:
Service Plan level: Go to Service Plans > Service Plan Name > PHP Settings
Domain level: Go to Domains > example.com > PHP Settings
Official Plesk documentation: Adding Custom PHP Versions (Linux)
hello i want to update PHP version because my laravel app version is newer then plesk version,please give me solution.
Hello @final coat app!
As I can see the most recent Laravel version requires PHP 7.1.3 or higher. Such PHP versions are provided by Plesk Onyx and may be installed at Tools & Settings > Updates and Upgrades > Add/Remove Components.
In case you have Plesk 12.5 or lower, the easiest solution would be to Upgrade to Plesk Onyx.
In case you want to install custom PHP version manually, follow the steps from this article.
thanks for replay,
my plesk version is onyx 17.5.3 (1.png) and in plesk server PHP version is 7.0.30 but my composer says your plesk version is 5.4.16 (2.png) ,please give me solution . see below images
Hello @final coat app, the reason of such behavior is that composer uses OS PHP version, not the PHP version set for subscription.
You may upgrade system PHP at your own risk. Alternatively, consider migration to Plesk server with OS supplied by more modern PHP version out of the box.
but my OS PHP version is 7.2.1 and plesk server version is 7.0.30 but error still come on composer update.composer show PHP version is 5.4.16
@final, could you, please, show the output of the following commands:
What would be the proper way to remove / rollback an installation made with the instructions in this article?
Besides, what if a new PHP configuration option is needed after installation?
Hello @Cirrus Tecnologia,
> What would be the proper way to remove / rollback an installation made with the instructions in this article?
1. Find ID of registered PHP
2. Unregister PHP from Plesk
/usr/local/psa/bin/php_handler --remove ID_from_step_1
Remove folder where PHP was compiled
> Besides, what if a new PHP configuration option is needed after installation?
Compile PHP again with new option
Please update this page so old php 5.6x will be useable with ubuntu 18.04. that comes only with php 7.2
Unfortunately I tried the above step and plesk show me PHP 5.6-40 but the domain was not able to connect to the Database.
Might someone help with this last step so this php5.6.40 addition will actually work?
/usr/local/psa/bin/php_handler --add -displayname <NN> -path <path to php cgi> -phpini <path to php.ini> -type <php handler> -id <NN-custom> -clipath <path to php cli>
This command was successfully used on my test machine:
/usr/local/psa/bin/php_handler --add -displayname 5.6.40 -path /usr/local/php56/bin/php-cgi -phpini /usr/local/lib/php.ini -type fastcgi -id PHP5.6.40 -clipath /usr/local/php56/bin/php
Check the following article, it is possible that mysql socket is not specified for 5.6.40: https://support.plesk.com/hc/en-us/articles/213394269-Unable-to-open-a-website-after-switching-to-additional-PHP-Error-establishing-a-database-connection
Yes this might include php 5.6, but has no mysql connection.
Please talk to your plesk colleague as i have received a working installation guide.
Just checked - it was needed to add the mysql module to the new PHP handler. Glad that you have found the cause!
After weeks I succeeded, I put the link of the commands to run on centos to install plesk with php + argon2
This may help other Plesk users, thank you.
Hi @Peer Hoffmann
Could you please elaborate on this? Please send me the error message, may be we have another article for your issue
this link does not work:
The article was deleted due to being non-actual.
I would suggest you checking other ones.
can you help me find an article that fixes the problem described in the article above?
As a troubleshooting step, try switching PHP version on a affected domain to another one in Domains > example.com > PHP Settings.
In case it'll make a trick, the most possible cause is that mysql socket isn't specified in php.ini for the previous chosen version of PHP.
The socket can be specified either in Plesk UI in Tools & Settings > PHP Settings > PHP 5.6 (chose the version according to your needs) or via command line:
# grep -ir mysql.sock /opt/plesk/php/5.6/etc/php.ini |grep -v ';'
mysql.default_socket = /var/lib/mysql/mysql.sock
Note: for Debian 9 the socket path should be
/var/run/mysqld/mysqld.sock.The path to php.ini should be adjusted according to the PHP version.
Re-apply PHP settings on a domain in Domains > example.com > PHP Settings after changes in main php.ini file.
If it won't help, submit a ticket to the Support Team to look deeper into the issue.
I am using Ubuntu 18.04. I am trying to install and register PHP5.3.29
I received no errors in the install or registration with Plesk.
I am getting the same mysql issue as above.
My php.ini file for 5.3.29 included the uncommented mysql.default_socket = line. Inserting the /var/lib...... did not fix the issue. Also, PHP 5.3.29 is installed in /usr/local/php-5.3.29, will that change anything?
In Tools & Settings > PHP Settings > PHP 5.3.29 no extensions are shown either. Do I have to install mysql for php5 as well as the other extensions?
If you don't have mysql or mysqli extension, then at least one of them should be installed to be able to establish MySQL connections when using this PHP.
> In Tools & Settings > PHP Settings > PHP 5.3.29 no extensions are shown either.
As for this issue, try to run this command:
Then, log in to Plesk as admin and go to Tools & Settings - Server Components and click "Refresh".
If it does not help, I suggest you contacting support at https://support.plesk.com/hc/en-us/requests/new.
For all that are in the need to compile PHP 5.6.0 to a plesk version so all will work including MYSQL:
This quire worked nice on my INTEL CPU machine with Ubuntu 18.04.
Plesk add custom PHP 5.6 with mysql module support on Ubuntu 18 (Intel cpu) :
1. Unpack sources
tar -xf php-5.6.40.tar
2. Install and configure required libraries:
apt-get install libbz2-dev libcurl4-gnutls-dev libdb-dev libenchant-dev libjpeg-turbo8-dev libpng-dev libxpm-dev libfreetype6-dev libgmp-dev libgmp3-dev libc-client-dev libkrb5-dev libmcrypt-dev unixodbc-dev libsqlite3-dev libedit-dev libreadline-dev libtidy-dev libxslt-dev php-dev
ln -s /usr/include/x86_64-linux-gnu/curl /usr/include/curl
ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h
3. Configure PHP:
./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 --build=x86_64-linux-gnu --host=x86_64-linux-gnu --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 --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 --with-imap=shared --with-imap-ssl --enable-mbstring=shared --enable-mbregex --with-gd=shared --enable-bcmath=shared --enable-dba=shared --with-xmlrpc=shared --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 --with-xsl=shared,/usr --enable-xmlreader=shared --enable-xmlwriter=shared --with-curl=shared,/usr --enable-pdo=shared --with-pdo-odbc=shared,unixODBC,/usr --with-pdo-mysql=shared,mysqlnd --with-pdo-sqlite=shared,/usr --with-sqlite3=shared --enable-json=shared --enable-zip=shared --without-readline --with-libedit --enable-phar=shared --with-mcrypt=shared,/usr --with-tidy=shared,/usr --with-unixODBC=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
4. From here we get patch to make 5.6 work with openssl 1.1:
patch -p1 < PHP-5.6.31-OpenSSL-1.1.0-compatibility-20170801.patch
6. Done, now a bit of PHP ocnfiguration + adding modules:
mkdir -p /opt/plesk/php/5.6.40/etc/php.d
cp php.ini-production /opt/plesk/php/5.6.40/etc/php.ini
7. Enable mysql module:
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" >> /opt/plesk/php/5.6.40/etc/php.ini
8. Register in Plesk:
/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
Thank you @Robert,
This may be useful for other Pleskians.
Ivan, i hope this guide still works as on my new sever Amd cpu I had some trouble with icu and intl library
Yes, it should work, thought we did not test it on all possible configurations (
Great @Robert, I was very helpful.
Running on Ubuntu 18.04 + Plesk 18.0.21
Thanks very much.
Thanks alot, but at my side (intel, 18.04) it does not find icu-config even it is installed. any idea?
Command 'icu-config' not found, but can be installed with:
apt install libicu-dev
root@erzingen:/tmp/php-5.6.40# apt install libicu-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libicu-dev is already the newest version (64.2-0.1+ubuntu18.04.1+deb.sury.org+1).
/root/php-5.4.0/ext/dom/node.c:1898:21: error: dereferencing pointer to incomplete type
ret = buf->buffer->use;
In file included from /root/php-5.4.0/main/php.h:38:0,
/root/php-5.4.0/ext/dom/node.c:1900:40: error: dereferencing pointer to incomplete type
RETVAL_STRINGL((char *) buf->buffer->content, ret, 1);
/root/php-5.4.0/Zend/zend_API.h:571:20: note: in definition of macro ‘ZVAL_STRINGL’
const char *__s=(s); int __l=l; \
/root/php-5.4.0/ext/dom/node.c:1900:5: note: in expansion of macro ‘RETVAL_STRINGL’
RETVAL_STRINGL((char *) buf->buffer->content, ret, 1);
make: *** [ext/dom/node.lo] Error 1
j'ai pas réussi à compiler la version 5.4.0 en ajoutant le patch avec des liens sur le web !
et j'ai pas la solution si il y a une personne qui sais ,
mon système : OS CentOS Linux 7.7
Plesk Obsidian Version 18.0.20
Hello @Michael, @azri mourad,
Please let me clarify that the steps provided in the article are for demonstration only and not supported by Plesk.
I suggest reviewing official PHP documentation for the necessary versions to clarify what exactly steps are required for the OSes and the desired environments.
Hello! I have added a custom php following the instructions above. When I don't need it anymore, how can I delete it. Thank you!
Please sign in to leave a comment.