Question
How to add a custom PHP version in Plesk for Linux?
Answer
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
1- 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.
-
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 --help
to see a list of the available options.# cd ../php-NN
# ./configure --prefix=/usr/local/phpNN --enable-fpm --with-fpm-group=www-data
# make
# make install
-
Set up the
php.ini
:Note: Edit the
.ini
file to set the desired PHP options. If it's required to configure thephp.ini
file in another location, run theconfigure
utility with the option--with-config-file-path=/some/path
in the previous step.# cp php.ini-development /usr/local/lib/php.ini
2- Register the custom PHP version in Plesk
-
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>
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 thedisplayname
, 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…
-