Home » Parallels » How to install and configure multiple php on Parallels

How to install and configure multiple php on Parallels

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.

[root@linuxpcfix ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Update/Install all the packages PHP will need.

[root@linuxpcfix ~]# yum -y install gcc make gcc-c++ cpp kernel-headers.x86_64 libx libjpeg-devel.x86_64 libpng-devel.x86_64 libjpeg-devel libmcrypt libmcrypt-devel libmcrypt-devel.x86_64 libmcrypt-devel.x86_64 bzip2-devel.x86_64 libxml2-devel.x86_64 patch gcc glibc libstdc++ gcc-c++ binutils libtool autoconf make

Download PHP 5.2.17 from source code.

[root@linuxpcfix ~]# wget http://museum.php.net/php5/php-5.2.xxx.tar.gz -O /usr/local/src/php-5.2.xxx.tar.gz

Extract PHP 5.2.xxx, and change to the new directory.

[root@linuxpcfix ~]# tar xzvf /usr/local/src/php-5.2.xxx.tar.gz -C /usr/local/src/
[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.

[root@linuxpcfix ~]# ./configure –with-libdir=lib64 –cache-file=./config.cache –prefix=/usr/local/php-5.2.17 –with-config-file-path=/usr/local/php-5.2.17/etc –disable-debug –with-pic –disable-rpath –with-bz2 –with-curl –with-freetype-dir=/usr/
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.

[root@linuxpcfix ~]# cp /usr/local/src/php-5.2.xxx/php.ini-recommended /usr/local/php-5.2.xxx/etc/php.ini

Include the timezone in the php.ini

[root@linuxpcfix ~]# sed -i “s#;date.timezone =#date.timezone = $timezone#” /usr/local/php-5.2.

Finally use the given below command to add the new PHP version to the Plesk Panel, PHP version selection.

[root@linuxpcfix ~]# /usr/local/psa/bin/php_handler –add -displayname “5.2.xxx” -path /usr/local/php-5.2.xxx/bin/php-cgi -phpini /usr/local/php-5.2.xxx/etc/php.ini -type fastcgi -id “fastcgi-5.2.xxx”

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 ~]# # cd /var/www/vhosts/linuxpcfix.com/cgi-bin
[root@linuxpcfix ~]# mkdir .cgi_wrapper
[root@linuxpcfix ~]# cd .cgi_wrapper

Create a new file, .phpwrapper, and append the following content:

[root@linuxpcfix ~]#vi .phpwrapper
#!/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 ~]# chgrp psaserv /var/www/vhosts/linuxpcfix.com/cgi-bin
[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 ~]# cd /var/www/vhosts/linuxpcfix.com/conf
[root@linuxpcfix ~]#vi vhost.conf

Append the following lines

<Directory /var/www/vhosts/linuxpcfix.com/httpdocs>
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:

[root@linuxpcfix ~]# /usr/local/psa/admin/sbin/httpdmng –reconfigure-domain linuxpcfix.com

Restart Apache:

[root@linuxpcfix ~]# /etc/init.d/httpd restart

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.

About

I am founder and webmaster of www.linuxpcfix.com and working as a Sr. Linux Administrator (Expertise on Linux/Unix & Cloud Server) and have been in the industry since more than 14 years.

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*

Time limit is exhausted. Please reload the CAPTCHA.

Categorized Tag Cloud