Two PHP versions linux Plesk HOWTO
Few days ago i was exchanging emails with Parallels support. I was asking them to help me to setup two php versions on linux plesk server. After few emails they answeared me that it is not possible. It didn't help when i told them that i was using fastcgi on my own hosting server and that i was having 3 php versions configurable per customer. Nop... Their answear was
Quote:
As of now there is no option available in the linux, where you can choose php as per the customers. Hope you are clear now. If you have any further help, feel free to get back to us. We would be glad to assist you further. |
So, i logged in to Plesk server and spend around 20 minutes planning how to intercept Plesk calls. And it is done.
For this to work you have to have php running as fastcgi (it is most secure way, so i assume that everyone is running php as fastcgi)
Here it goes:
1. ssh to your plesk server, download php source, unpack it and configure it
Code:
ssh yourserver -l root cd /usr/local/src mkdir php540 cd php540 wget http://www.php.net/get/php-5.4.0.tar.gz/from/at2.php.net/mirror tar xzvf php-5.4.0.tar.gz cd php-5.4.0
Code:
./configure '--with-libdir=lib64' '--cache-file=../config.cache' '--prefix=/usr/local/php536-cgi' '--with-config-file-path=/usr/local/php536-cgi/etc' '--disable-debug' '--with-pic' '--disable-rpath' '--with-bz2' '--with-curl' '--with-freetype-dir=/usr/local/php536-cgi' '--with-png-dir=/usr/local/php536-cgi' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr/local/php536-cgi' '--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' '--without-sqlite3' '--with-libxml-dir=/usr/local/php536-cgi' '--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/php536-cgi/pear' '--with-mcrypt' '--enable-intl' '--without-pdo-sqlite' '--with-config-file-scan-dir=/usr/local/php536-cgi/php.d' '--enable-zip'
Choosing a prefix is a MUST because that way your new php installation will not interfere with older php used by plesk.
2. compile your php
Code:
make
Code:
make install
for example, let's say that you have a customer blabla.com that uses some newer php functions that don't exist in php 5.1. Let's call that customer blabla.com. For him we will tell apache to use our new php (5.4.0)
Code:
cd /var/www/vhosts/blabla.com/cgi-bin mkdir .cgi_wrapper cd .cgi_wrapper
Code:
vi .phpwrapper
Code:
#!/bin/sh export PHPRC=/var/www/vhosts/blabla.com/etc/ export PHP_FCGI_CHILDREN=4 export PHP_FCGI_MAX_REQUESTS=1000 exec /usr/local/php540-cgi/bin/php-cgi
Code:
cd /var/www/vhosts/blabla.com/cgi-bin chmod 101 .cgi_wrapper chmod 500 .cgi_wrapper/.phpwrapper chown blabla.com:psacln .cgi_wrapper -R chattr -R +i .cgi_wrapper
5. make apache aware of our wrapper
plesk offers a functionality of changing httpd setup per host. we will use that functionality to tell apache that for blabla.com it needs to use our new wrapper, instead of one provided by plesk:
we will create file named vhost.conf
file content:
So, we have told apache not to use plesk php wrapper (RemoveHandler fcgid-script) and instead of that we have created a new handler for php files. When executing php files on blabla.com domain apache will call our wrapper and use new php that we installed
6. we need to reconfigure blabla.com domain
7. and restart apache
That's it. For every domain that needs some extra functions provided only in php versions newer than one provided with your plesk distro you can do steps 4,5,6 and 7 (replace blabla.com with your customer domain name) and that's all.
Adicional: A veces podemos necesitar instalar este paquete yum-install libtool-ltdl-devel
plesk offers a functionality of changing httpd setup per host. we will use that functionality to tell apache that for blabla.com it needs to use our new wrapper, instead of one provided by plesk:
Code:
cd /var/www/vhosts/blabla.com/conf
Code:
vi vhost.conf
Code:
RemoveHandler fcgid-script AddHandler fcgid-script .php SetHandler fcgid-script FCGIWrapper /var/www/vhosts/blabla.com/cgi-bin/.cgi_wrapper/.phpwrapper .php Options +ExecCGI allow from all
6. we need to reconfigure blabla.com domain
Code:
/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain blabla.com
Code:
/etc/init.d/httpd restart
Adicional: A veces podemos necesitar instalar este paquete yum-install libtool-ltdl-devel
No hay comentarios:
Publicar un comentario