How to add a custom PHP version in Plesk for Linux?

Follow

Comments

41 comments

  • Avatar
    final coat app (Edited )

    hello i want to update PHP version because my laravel app version is newer then plesk version,please give me solution.

    -1
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    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.

     

    0
    Comment actions Permalink
  • Avatar
    final coat app (Edited )

    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

    0
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    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.

    0
    Comment actions Permalink
  • Avatar
    final coat app

    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

    0
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    @final, could you, please, show the output of the following commands:

    plesk -v

    php -v

    0
    Comment actions Permalink
  • Avatar
    Cirrus (Edited )

    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?

    0
    Comment actions Permalink
  • Avatar
    Pavel Rozental

    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
    /usr/local/psa/bin/php_handler --list
    2. Unregister PHP from Plesk
    /usr/local/psa/bin/php_handler --remove ID_from_step_1
    3. Optionally:
    Remove folder where PHP was compiled

    > Besides, what if a new PHP configuration option is needed after installation?

    Compile PHP again with new option

    0
    Comment actions Permalink
  • Avatar
    Robert Krölls

    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>

    0
    Comment actions Permalink
  • Avatar
    Alisa Kasyanova

    @Robert
    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

    0
    Comment actions Permalink
  • Avatar
    Robert Krölls

    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.

    0
    Comment actions Permalink
  • Avatar
    Alisa Kasyanova

    @Robert
    Just checked - it was needed to add the mysql module to the new PHP handler. Glad that you have found the cause!

    0
    Comment actions Permalink
  • Avatar
    Sergio Caramanno

    After weeks I succeeded, I put the link of the commands to run on centos to install plesk with php + argon2

    https://github.com/xdasty/plesk-php-argon2

     

     

     

    0
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    @dasty,

    This may help other Plesk users, thank you.

    0
    Comment actions Permalink
  • Avatar
    Lev Iurev

    Hi @Peer Hoffmann

    Could you please elaborate on this? Please send me the error message, may be we have another article for your issue

    0
    Comment actions Permalink
  • Avatar
    Anzhelika Khapaknysh

    Hi @kriskrkpl,

    The article was deleted due to being non-actual.
    I would suggest you checking other ones.

    0
    Comment actions Permalink
  • Avatar
    kriskrkpl

    can you help me find an article that fixes the problem described in the article above?

    0
    Comment actions Permalink
  • Avatar
    Anzhelika Khapaknysh (Edited )

    @kriskrkpl,

    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:

    1. Connect to the server via SSH and add the following line in the corresponding php.ini file:
      # 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.
    2. 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.

    0
    Comment actions Permalink
  • Avatar
    Nathan Wilson

    Hi Anzhelika,

    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?

     

    0
    Comment actions Permalink
  • Avatar
    Bulat Tsydenov

    Hi Nathan,

    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:

    # /usr/local/psa/admin/bin/packagemng --set-dirty-flag

    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.

    0
    Comment actions Permalink
  • Avatar
    Robert Krölls

    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
    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
    cd php-5.6.40/

    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:
    https://github.com/oerdnj/deb.sury.org/issues/566

    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

    5. Complilation:
    make
    make install

    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:
    cd ./ext/mysql
    phpize
    ./configure --with-php-config=/opt/plesk/php/5.6.40/bin/php-config
    make
    make install

    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

    1
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    Thank you @Robert, 

    This may be useful for other Pleskians.

    0
    Comment actions Permalink
  • Avatar
    Robert Krölls

    Ivan, i hope this guide still works as on my new sever Amd cpu I had some trouble with icu and intl library

    0
    Comment actions Permalink
  • Avatar
    Anton Maslov

    Yes, it should work, thought we did not test it on all possible configurations (

    0
    Comment actions Permalink
  • Avatar
    Rubén Ramos (Edited )

    Great @Robert, I was very helpful.

    Running on Ubuntu 18.04 + Plesk 18.0.21

    Thanks very much.

    0
    Comment actions Permalink
  • Avatar
    Michael (Edited )

    Thanks alot, but at my side (intel, 18.04) it does not find icu-config even it is installed. any idea?

    icu-config

    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).

    0
    Comment actions Permalink
  • Avatar
    azri mourad

    bonjour

     
    j'ai le problème suivant 
    je viens de faire les étapes d'installation de php-5.4.0 pour plesk comme sur la proposition de Ekaterina Babenko 
    Mais à la commande de (#make)  j'ai une erreur :
     

    /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,

                     from /root/php-5.4.0/ext/dom/node.c:26:

    /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

     

     

     

    0
    Comment actions Permalink
  • Avatar
    Maxim Krasikov

    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.

    2
    Comment actions Permalink
  • Avatar
    Vương Công Minh

    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!

    0
    Comment actions Permalink

Please sign in to leave a comment.

Have more questions? Submit a request