Knowledgebase

Perfectly Installing PHP 5.6 in CWP

Using this tutorial will replace your current working version of php with v5.6 and all files will get installed to /usr/local/php/.

Lets proceed with PHP 5.6 Installation.

1) Enable epel repository.

rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

2)
Download needed dependencies.

yum -y install gcc make gcc-c++ cpp kernel-headers.x86_64 \
	libxml2-devel openssl-devel bzip2-devel libjpeg-devel \
	libpng-devel freetype-devel openldap-devel postgresql-devel \
	aspell-devel net-snmp-devel libxslt-devel libc-client-devel \
	libicu-devel gmp-devel curl-devel libmcrypt-devel pcre-devel \
	sqlite-devel db4-devel enchant-devel libXpm-devel mysql-devel \
	readline-devel libedit-devel recode-devel libtidy-devel libtool-ltdl-devel
	

3)
Download and create installation path.

mkdir -p /usr/local/php-5-6
cd /usr/local/php-5-6
wget http://php.net/distributions/php-5.6.7.tar.gz
tar zxvf php-5.6.7.tar.gz
cd php-5.6.7

4) Configure and Install PHP 5.6.

./configure --with-bz2 \
	--prefix=/usr/local/php \
	--with-apxs2 \
	--with-curl \
	--with-libdir=/usr/lib64 \
	--with-config-file-path=/usr/local/php \
	--with-config-file-scan-dir=/usr/local/php/php.d \
	--with-iconv \
	--with-gd \
	--with-jpeg-dir=/usr/local/php \
	--with-png-dir \
	--with-freetype-dir=/usr/local/php \
	--enable-gd-native-ttf \
	--with-kerberos \
	--enable-mbstring \
	--with-mcrypt \
	--with-mhash \
	--with-mysql \
	--with-sqlite3 \
	--with-mysql=mysqlnd \
	--with-mysqli=mysqlnd \
	--with-mysql-sock=/var/lib/mysql/mysql.sock \
	--with-xsl \
	--with-pspell \
	--with-openssl \
	--with-gettext \
	--with-pcre-regex \
	--with-libxml-dir=/usr/local/php \
	--with-pdo-mysql \
	--with-regex \
	--with-pic \
	--with-pear=/usr/local/php/pear \
	--with-gmp \
	--enable-zip \
	--with-zlib \
	--enable-inline-optimization \
	--enable-mbregex \
	--enable-opcache \
	--enable-fpm \
	--enable-posix \
	--enable-calendar \
	--enable-bcmath \
	--enable-exif \
	--enable-phar \
	--enable-ftp \
	--enable-pdo \
	--enable-soap \
	--enable-sockets \
	--enable-intl \
	--with-xmlrpc \
	--without-pdo-sqlite

make && make install

5) Copy working php.ini file.

rm -rf /usr/local/php/php.ini
cp php.ini-production /usr/local/php/php.ini

6)
Enable extension directiory.

echo "extension_dir='/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226'" >> /usr/local/php/php.ini



7)
Symlink PHP 5.6 path.

rm -rf /usr/local/bin/php
ln -s /usr/local/php/bin/php /usr/local/bin/php

8) Restart Apache.

service httpd restart

9) Check php version.

php -v
  • 12 Users Found This Useful
Was this answer helpful?