Tuesday, August 23, 2011

Confgure custom php for a particular domain

php 5.3.6 is currently not available in the easy apache script. So if any user want to use thi version in a shared cpanel server, we can manually compile and then enable this version for that user using an htaccess rule.

==============
cd /usr/src

wget http://in2.php.net/get/php-5.3.7.tar.gz/from/us.php.net/mirror

tar -zxf php-5.3.7.tar.gz

cd php-5.3.7

use the same configure option as of 5.3.6 and give the prefix as say for example /usr/local/jibin/php5.3/

=================
./configure --prefix=/usr/local/jibin/php5.3 --enable-bcmath --enable-calendar --enable-ftp --enable-gd-native-ttf --enable-libxml --enable-mbstring --enable-pdo=shared --enable-sockets --enable-wddx --enable-zend-multibyte --enable-zip --with-curl=/opt/curlssl/ --with-curlwrappers --with-freetype-dir=/usr --with-gd --with-gettext --with-imap=/opt/php_with_imap_client/ --with-imap-ssl=/usr --with-jpeg-dir=/usr --with-kerberos --with-libexpat-dir=/usr --with-libxml-dir=/opt/xml2/ --with-mcrypt=/opt/libmcrypt/ --with-mhash=/opt/mhash/ --with-mysql --with-mysqli --with-openssl=/usr --with-openssl-dir=/usr --with-pcre-regex=/opt/pcre --with-pdo-mysql=shared --with-pdo-sqlite=shared --with-png-dir=/usr --with-pspell --with-sqlite=shared --with-tidy=/opt/tidy/ --with-xmlrpc --with-xpm-dir=/usr --with-xsl=/opt/xslt/ --with-zlib --with-zlib-dir=/usr
=================

make

make install

copy the php.ini file from the location /usr.local/lib/php.ini.

cp /usr/local/lib/php.ini /usr/local/jibin/php5.3/lib/

NOTE: Please edit the file php.ini i.e extensions and change the path to /usr/local/jibin/php5.3/lib/php/extensions

Once compiled you can check the version using the command

/usr/local/php-5.3.7/bin/php-cgi -v

add the following line in the section “handlers” in the suphp.conf file if the default php in the server is compiled as suphp

vi /opt/suphp/etc/suphp.conf

application/x-httpd-php5.3=”php:/usr/local/jibin/php5.3/bin/php-cgi”

Now add the rule to the file “pre_main_2.conf” for enabling this version for any particulkar domain.

vi /usr/local/apache/conf/includes/pre_main_2.conf


Allow from All


suPHP_AddHandler application/x-httpd-php5.3
AddType application/x-httpd-php5.3 .php


No comments:

Post a Comment