Wednesday, 28 May 2014

install alternate PHP version along with current version

Requirement: The client is hosted on a server with php 5.3 and he want to enable  5.4 for his domain. To this, we are installing php 5.4 to another location in  the same server.
1. cd /usr/src
2. Download PHP version from http://in3.php.net/get/php-5.4.28.tar.gz/from/a/mirror using wget
3. tar -xzvf php-5.4.28.tar.gz
4. cd php-5.4.28
5. Make sure the installation path --prefix is specified and is compiled as cgi using the option --enable-cgi. In this case I am using the installation path as --prefix=/usr/local/php54
Make sure to remove the configuration parameter for apxs  ie   --with-apxs2=/usr/local/apache/bin/apxs

./configure  --disable-fileinfo --disable-phar --enable-bcmath --enable-calendar --enable-libxml --enable-mbstring --enable-pdo=shared --enable-soap --enable-sockets --enable-wddx --enable-zend-multibyte --enable-zip --prefix=/usr/local/php54 --enable-cgi --with-bz2 --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-libdir=lib64 --with-libexpat-dir=/usr --with-libxml-dir=/opt/xml2/ --with-mcrypt=/opt/libmcrypt/ --with-mm=/opt/mm/ --with-mysql=/usr --with-mysql-sock=/var/lib/mysql/mysql.sock --with-mysqli=/usr/bin/mysql_config --with-openssl=/usr --with-openssl-dir=/usr --with-pcre-regex=/opt/pcre --with-pdo-mysql=shared --with-pdo-sqlite=shared --with-pic --with-png-dir=/usr --with-pspell --with-tidy=/opt/tidy/ --with-xmlrpc --with-xpm-dir=/usr --with-xsl=/opt/xslt/ --with-zlib --with-zlib-dir=/usr

6. make
7. make install

Now, check if binary is installed:
===
/usr/local/php5/bin/php-cgi -v
===
It should show as cgi.
Now add the following lines on top of the httpd.conf file
===
ScriptAlias /php54/ /usr/local/php54/bin/
Action application/x-httpd-php54 /php54/php-cgi
<Directory “/usr/local/php54/bin/”>
Allow from all
</Directory>
===
Save httpd.conf file and restart apache.
Open a .htaccess file inside the folder where you need php5 and add the following code to it. Make sure .htaccess support is enabled in your apache configuration.
===
AddHandler application/x-httpd-php54 .php
===
Make a phpinfo.php file in this directory and see what is shows when taken in browser. It should be php5.4

No comments:

Post a Comment