Tuesday, August 30, 2016

Install php 5.4 on CentOS 6 with yum command

Install stomp via pecl on

pecl install stomp

php -m |grep -i stomp
Stomp

----------------------------------------------------------------------------------------------------------

In this post we will install php 5.4 on CentOS 6 with yum command . In available default repo of CentOS, we will get the php 5.3 version. Some PHP developers uses the PHP 5.4 version for application, hence we need PHP 5.4 to be installed on CentOS 6.x .

It is known that in CentOS 6 series versions, we can not get the PHP 5.4 version from default yum repo .
To install php 5.4 on CentOS 6.x, we will use the SCL repo. In terms of SoftwareCollections.org (SCL), “Software Collections give you the power to build, install, and use multiple versions of software on the same system, without affecting system-wide installed packages.”
Lets start the installation of PHP 5.4 .
Step 1. Install SCL repo only by hitting below given command.
yum install centos-release-SCL
Step 2. Install php 5.4 version on system now.
yum install php54
To install specific package, package name should be known. Hence, to get the list of available package list from SCL repo run below given command.
yum list|grep php
Step 3. Activate the PHP 5.4 on system.
NOTE: If you run below given command directly from terminal then on next login you will not find PHP 5.4 path.
source /opt/rh/php54/enable
Basically the above command, make PHP 5.4 executable path and environment available to current login user.
To make PHP 5.4 available to all user , we have to add line source /opt/rh/php54/enable inside file called /etc/profile. Now activate without logout by running command.
source /etc/profile
Or in case, if you only want php 5.4 available to specific user then just only edit .bashrc or .bash_profile file from User’s home directory. And add line source /opt/rh/php54/enable .
Step 4. Now check the php version
php -v
Below given is reference from our system.
[root@localhost ~]# php -v
PHP 5.4.16 (cli) (built: Nov 19 2014 08:05:17) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
[root@localhost ~]# 
IMPORTANT NOTE : The PHP 5.4 package actually installed in /opt/rh directory.

Install mcrypt PHP module 
# install EPEL with yum
yum -y install epel-release
# install php-mcrypt
yum -y install php-mcrypt

Try running the following commands:
wget http://dl.fedoraproject.org/pub/epel/beta/7/x86_64/epel-release-7-1.noarch.rpm
rpm -ivh epel-release-7-1.noarch.rpm
yum install --enablerepo="epel" php-mcrypt

wget http://dl.fedoraproject.org/pub/epel/beta/7/x86_64/epel-release-7-1.noarch.rpm

No comments:

Post a Comment