Aggiungere una versione PHP personalizzata in Plesk su Unix

Versione del 11 ago 2023 alle 14:28 di Andrea (discussione | contributi) (Creata pagina con "← Torna ad Plesk Category:Plesk How to add a custom PHP version in Plesk for Linux? fonte: https://support.plesk.com/hc/en-us/articles/1150004978...")
(diff) ← Versione meno recente | Versione attuale (diff) | Versione più recente → (diff)

← Torna ad Plesk

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

fonte: https://support.plesk.com/hc/en-us/articles/115000497853-How-to-add-a-custom-PHP-version-

Install the custom PHP version

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.

  1. Connect to the server via SSH
  2. Install C compiler and XML library with the following commands:
    apt-get install build-essential && apt-get install libxml2-dev
  3. 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:
    tar -xf php-NN.tar
  4. Configure and build PHP:
    1. cd ../php-NN
    2. ./configure --prefix /usr/local/phpNN --enable-fpm --with-fpm-group=www-data#: ./configure --prefix /usr/local/phpNN --enable-fpm --with-fpm-group=www-data
      esempio: ./configure --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-soap --prefix /usr/local/php56 --with-config-file-path=/usr/local/php56/php.ini --enable-fpm --with-fpm-group=psacln
    3. make
    4. make install
  5. Set up the php.ini:
    cp php.ini-development /usr/local/php56/php.ini
--with-openssl --with-system-ciphers
--with-openssl=/usr/lib/ssl
--with-openssl-dir=/usr/include/openssl
--with-openssl-includes=/usr/include/openssl/ --with-openssl-libraries=/usr/include/openssl/

Register the custom PHP version in Plesk

  1. Connect to the server via SSH
  2. Register the new PHP version in Plesk:
    • 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>
      Where:
      • 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: 7.4.5-custom
      • 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 install in 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 install in 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.ini file, for example: /usr/local/lib/php.ini
      • 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
      • (Optional) 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_handlers utility
      esempio:

per installarlo

/usr/sbin/plesk bin php_handler --add -displayname 7.3.33-custom -path /usr/local/php73/bin/php-cgi -phpini /usr/local/lib/php73/php.ini -type fastcgi -id 7.3.33-custom -clipath /usr/local/php73/bin/php
/usr/sbin/plesk bin php_handler --add -displayname 5.6.40-custom -path /usr/local/php56/bin/php-cgi -phpini /usr/local/php56/php.ini -type fastcgi -id 5.6.40-custom -clipath /usr/local/php56/bin/php

per rimuoverlo

/usr/sbin/plesk bin php_handler --remove -id 7.3.33-custom
/usr/sbin/plesk bin php_handler --remove -id 5.6.40-custom

Assign the custom PHP version (Plesk GUI)

  1. Log in to Plesk GUI
  2. 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