- Plesk for Linux
How to add a custom PHP version?
Warning: ALL THE INSTRUCTIONS BELOW ARE TO BE PERFORMED AT OWN WILL AND RISK
On Linux systems, you can install any PHP version you need and then make it available in Plesk by registering it with the
To add an arbitrary PHP version in Plesk:
- Install the desired PHP version on your 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.
Warning: These steps are provided for demonstration purposes only and not supported by Plesk. Depending on your operating system and the desired configuration, installation steps can differ significantly. When you install an additional PHP version on your server, read the official PHP documentation on installation.
- 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
- Obtain the PHP source you need from the official website (http://php.net/downloads.php or http://php.net/releases/) and unpack it:
# gunzip php-NN.tar.gz
# tar -xf php-NN.tar
- Configure and build PHP. This is when you can customize PHP with various options, such as specifying which extensions will be enabled. Run
./configure --helpfor a list of available options.
# cd ../php-NN
# ./configure --prefix /usr/local/phpNN
# make install
- Set up your
# cp php.ini-development /usr/local/lib/php.ini
You may edit your
.inifile to set PHP options. If you prefer having
php.iniin another location, run the
configureutility with the option
--with-config-file-path=/some/pathin step 3.
- Register the new PHP version in Plesk:
# /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>
-displayname<NN> is the PHP version name that will be shown in the Plesk UI. We recommend that you include the version number in the
displayname, for example, you can name the version "5.3.3-custom".
-path<path to php cgi> is the location of the PHP CGI binary file. You can find this in the output of the command
make installin the line Installing PHP CGI binary. For example, if you see the line Installing PHP CGI binary: /usr/local/bin/, the location you need 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> is the location of the PHP CLI binary file. You can find this in the output of the command make install in the line Installing PHP CLI binary. For example, if you see the line Installing PHP CLI binary: /usr/local/bin/, the location you need to specify is /usr/local/bin/php. Learn more at http://php.net/manual/en/install.unix.commandline.php.
-phpini<path to php.ini> is the location of the
php.inifile, for example,
-type<php handler> is the type of the PHP handler associated with this version. Learn more about PHP handlers in the section PHP Handlers.
Note: Important: Either the CGI or FastCGI PHP handler can be set. mod_php is not supported.
-id<NN-custom> is the identifier that you will use for referring to this PHP version when adjusting or removing it.
After you register the PHP version in Plesk, it will be available for selection in service plan settings (Service Plans > plan name > PHP Settings) and in the PHP settings individual websites (Websites & Domains > PHP Settings). See the picture below.
Note: The aforementioned example is for CGI handlers. If FPM handler is needed, some extra information such as the <service name> the <path to the pool.d directory> will be needed.
More information on this can be seen through the command below:
# /usr/local/psa/bin/php_handler --help
Check our official Plesk documentation in order to install your custom PHP version.