Linux Parallels Plesk is supported to install multiple php versions on the server since 11.5 version. Follow the below Instructions for install and configure multiple php on Parallels Plesk 11.0.9 and 11.5 servers.
NOTE: The following instructions are applicable for Parallels Plesk 11.0.9 only. For Plesk 11.5, use the official documentation at parallels website.
Here are the steps we are going to install PHP 5.2.17 on CentOS 6.4 x64.
Update the system and packages
Install the EPEL repository.
Update/Install all the packages PHP will need.
Download PHP 5.2.17 from source code.
Extract PHP 5.2.xxx, and change to the new directory.
[root@linuxpcfix ~]# cd /usr/local/src/php-5.2.xxx/
Configure PHP
If you receive any configure errors you’ll need to diagnose specifically for your system, but most common error is because you’re missing required packages.
local/php-5.2.17 –with-png-dir=/usr/local/php-5.2.17 –enable-gd-native-ttf –without-gdbm –with-gettext –with-gmp –with-iconv –with-jpeg-dir=/usr/local/php-5.2.17 –with-openssl –with-pspell –with-pcre-regex –with-zlib –enable-exif –enable-ftp –enable-sockets –enable-sysvsem –enable-sysvshm –enable-sysvmsg –enable-wddx –with-kerberos –with-unixODBC=/usr –enable-shmop –enable-calendar –with-libxml-dir=/usr/local/php-5.2.17 –enable-pcntl –with-imap –with-imap-ssl –enable-mbstring –enable-mbregex –with-gd –enable-bcmath –with-xmlrpc –with-ldap –with-ldap-sasl –with-mysql=/usr –with-mysqli –with-snmp –enable-soap –with-xsl –enable-xmlreader –enable-xmlwriter –enable-pdo –with-pdo-mysql –with-pdo-pgsql –with-pear=/usr/local/php-5.2.17/pear –with-mcrypt –without-pdo-sqlite –with-config-file-scan-dir=/usr/local/php-5.2.17/php.d –enable-fastcgi
[root@linuxpcfix ~]make && make install
Now copy the php.ini to as given below.
Include the timezone in the php.ini
Finally use the given below command to add the new PHP version to the Plesk Panel, PHP version selection.
Create a PHP wrapper. For example, you have domain with name linuxpcfix.com and want to assign php version 5.2.17 for this domain.
Note :: Here we assume that plesk by default installed 5.3.x php version and replace the 5.2.xxx with actuall PHP version.(Here we are using php 5.2.17 version)
[root@linuxpcfix ~]# mkdir .cgi_wrapper
[root@linuxpcfix ~]# cd .cgi_wrapper
Create a new file, .phpwrapper, and append the following content:
#!/bin/sh
export PHPRC=/var/www/vhosts/linuxpcfix.com/etc/
export PHP_FCGI_CHILDREN=4
export PHP_FCGI_MAX_REQUESTS=1000
exec /usr/local/php-5.2.17/bin/php-cgi
Assign the required chmod and chown for the files and directories as you have created:
[root@linuxpcfix ~]# cd /var/www/vhosts/linuxpcfix.com/cgi-bin
[root@linuxpcfix ~]# chmod 101 .cgi_wrapper
[root@linuxpcfix ~]# chmod 500 .cgi_wrapper/.phpwrapper
[root@linuxpcfix ~]# chown linuxpcfix.com:psacln .cgi_wrapper -R
[root@linuxpcfix ~]# chattr -R +i .cgi_wrapper
Make sure Apache server aware of new PHP wrapper. Plesk allows an option to modify the httpd configuration per virtual host (it could be either a domain or subdomain). Here we will use that option to tell Apache web server that, as per our instance, linuxpcfix.com requires to use new PHP wrapper instead of provided by Plesk:
[root@linuxpcfix ~]#vi vhost.conf
Append the following lines
RemoveHandler fcgid-script
<IfModule mod_fcgid.c>
AddHandler fcgid-script .php
<Files ~ (\.php)>
SetHandler fcgid-script
FCGIWrapper /var/www/vhosts/linuxpcfix.com/cgi-bin/.cgi_wrapper/.phpwrapper .php
Options +ExecCGI
allow from all
</Files>
</IfModule>
</Directory>
According this file you have told Apache web server not to use the default Plesk PHP wrapper, we created a new handler for PHP files. While executing PHP files on the “linuxpcfix.com” domain, Apache will call the new PHP wrapper and use the php 5.2.17 version .
Reconfigure the “linuxpcfix.com” domain:
Restart Apache:
If you have multiple domain hosted on your server then you need to follow the same steps for each domain to enable the extra php version.
Note :: Replacing “linuxpcfix.com” with your actual domain name.