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

Follow

Comments

40 comments

  • Avatar
    Ivan Postnikov

    Hello Vương Công Minh

    To unregister handler from Plesk you will need this command:

    plesk bin php_handler --remove -id 123

    ID 123 is n example, for more information use this documentation article: https://docs.plesk.com/en-US/obsidian/cli-linux/using-command-line-utilities/php_handler-php-handlers.72490/

    Custom PHP version packages are to be removed from the server manually.

     

    0
    Comment actions Permalink
  • Avatar
    moonone

    Hello

    Here are the steps I have used to achieve the installation of php 5.6 on Debian 10 (Buster) with Plesk 18.0.29

    Installation of PHP 5.6
    - Source : https://deb.sury.org/
    - Source : https://www.howtoforge.com/tutorial/how-to-install-php-7-for-ispconfig-3-from-debian-packages-on-debian-8-and-9/

     

    Commands :

    sudo apt update
    sudo apt upgrade

    sudo apt install ca-certificates apt-transport-https lsb-release
    wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
    echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list

    sudo apt update
    sudo apt-get install php5.6 php5.6-cli php5.6-cgi php5.6-fpm php5.6-gd php5.6-mysql php5.6-imap php5.6-curl php5.6-intl php5.6-pspell php5.6-recode php5.6-sqlite3 php5.6-tidy php5.6-xmlrpc php5.6-xsl php5.6-zip php5.6-mbstring php5.6-soap php5.6-opcache libicu65 php5.6-common php5.6-json php5.6-readline php5.6-xml

    /usr/local/psa/bin/php_handler --add -displayname 5.6.40 -path /usr/bin/php-cgi5.6 -phpini /etc/php/5.6/php.ini -type fastcgi -id 5.6.40 -clipath /usr/bin/php5.6

    Hope it helps

    Kind regards

    6
    Comment actions Permalink
  • Avatar
    Alexey Lapshin

    Hello @moonone

    Thank you for sharing this!

    0
    Comment actions Permalink
  • Avatar
    moonone (Edited )

    You're welcome ! @...

    Don't hesitate to vote "yes" with the arrow up icon on any of those comments you find useful.

     

    Regards

    1
    Comment actions Permalink
  • Avatar
    Joe

    @Robert unfortunately php installed using your guide result in php files being downloaded instead of executed.

    However this guide for Ubuntu 18 worked for me https://dx3webs.com/blog/enable-php-56-ubuntu-plesk-1804

    0
    Comment actions Permalink
  • Avatar
    Stefano Poggioli

    How can I add the older PHP version in Plesk GUI as mod_php and not FastCGI ?
    Thanks in advance

    0
    Comment actions Permalink
  • Avatar
    John D'Orazio

    I tried following the instructions here and in the Official Documentation Page, to add PHP 8.1 as a handler, seeing that it will probably be a while before it becomes available in Plesk. However I would like to start testing it on some projects of mine, so I would like to be able to assign "PHP 8.1" to the subdomains of my choosing.

    After installing PHP 8.1 on my system using Ondrej Sury's deb repository, and installing the related extensions, I ran this command:

     sudo plesk bin php_handler --add -displayname "PHP 8.1" -path /usr/bin/php8.1 -clipath /usr/bin/php8.1 -phpini /etc/php/8.1/php.ini -type fpm -service php8.1-fpm -poold /etc/php/8.1/fpm/pool.d

    However when attempting to select "PHP 8.1" for a subdomain I get this error:

    phpinimng failed: configuration test '['/usr/bin/php8.1', '--test']' failed with code 1, and message: Error in argument 1, char 1: no argument for option - Usage: php8.1 [options] [-f] <file> [--] [args...] php8.1 [options] -r <code> [--] [args...] php8.1 [options] [-B <begin_code>] -R <code> [-E <end_code>] [--] [args...] php8.1 [options] [-B <begin_code>] -F <file> [-E <end_code>] [--] [args...] php8.1 [options] -S <addr>:<port> [-t docroot] [router] php8.1 [options] -- [args...] php8.1 [options] -a -a Run as interactive shell (requires readline extension) -c <path>|<file> Look for php.ini file in this directory -n No configuration (ini) files will be used -d foo[=bar] Define INI entry foo with value 'bar' -e Generate extended information for debugger/profiler -f <file> Parse and execute <file>. -h This help -i PHP information -l Syntax check only (lint) -m Show compiled in modules -r <code> Run PHP <code> without using script tags <?..?> -B <begin_code> Run PHP <begin_code> before processing input lines -R <code> Run PHP <code> for every input line -F <file> Parse and execute <file> for every input line -E <end_code> Run PHP <end_code> after processing all input lines -H Hide any passed arguments from external tools. -S <addr>:<port> Run with built-in web server. -t <docroot> Specify document root <docroot> for built-in web server. -s Output HTML syntax highlighted source. -v Version number -w Output source with stripped comments and whitespace. -z <file> Load Zend extension <file>. args... Arguments passed to script. Use -- args when first argument starts with - or script is read from stdin --ini Show configuration file names --rf <name> Show information about function <name>. --rc <name> Show information about class <name>. --re <name> Show information about extension <name>. --rz <name> Show information about Zend extension <name>. --ri <name> Show configuration for extension <name>.

    Any ideas on what the problem could be or how to fix it?

     

    0
    Comment actions Permalink
  • Avatar
    Samuel Boczek

    John D'Orazio, I think you need to specify the php-fpm binary for the -path argument, not the cli php binary. In your case the argument would probably look like this:

    -path /usr/sbin/php8.1-fpm
    0
    Comment actions Permalink
  • Avatar
    John D'Orazio

    Samuel Boczek thank you for pointing me in the right direction. Using the php-fpm binary in the -path argument, and also fixing the correct location of php.ini both made it work, I used this:

    sudo plesk bin php_handler --add -displayname "PHP 8.1" -path /usr/sbin/php-fpm8.1 -clipath /usr/bin/php8.1 -phpini /etc/php/8.1/fpm/php.ini -type fpm -service php8.1-fpm -poold /etc/php/8.1/fpm/pool.d

    And now I can correctly assign PHP 8.1 to a subdomain without any errors.

    0
    Comment actions Permalink
  • Avatar
    youssef yamani

    hello i'm on ubuntu 14 and plesk 17.1 i need php 7.4 but the problem i cant format the server since there is a webmail service that it used by a client and cant stop it. is there a way to manually add php 7.4 because in 17.8 there is 7.3.5 but not 7.4 why ?

    0
    Comment actions Permalink

Please sign in to leave a comment.

Have more questions? Submit a request