Is php5.5 or php5.6 Available for CentOS 7?
2 Answers
Yes, it is available for CentOS 7. You just have to add "Webtatic EL yum repository" information corresponding to your CentOS/RHEL version to yum, like :
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
You can install php now, using :
yum install php56w php56w-opcache
Once completed, check php version by using command,
php -v
Update
as suggested by @jsbillings, Webtatic is listed as one of the 'known problem' repos on the CentOS Wiki. You can use IUS or SCL from CentOS Wiki instead of Webtatic.
-
So I did what you suggested and it is still showing PHP 5.4.16 after I ran php -vTwitchedOut– TwitchedOut2016-06-16 21:00:02 +00:00Commented Jun 16, 2016 at 21:00
-
@TwitchedOut did you get any error while performing any steps which I mentioned ?Rahul– Rahul2016-06-17 04:39:01 +00:00Commented Jun 17, 2016 at 4:39
-
1Webtatic is listed as one of the 'known problem' repos on the CentOS Wiki. Better to suggest IUS or SCL.jsbillings– jsbillings2016-06-20 00:27:19 +00:00Commented Jun 20, 2016 at 0:27
-
@jsbillings ah, you are right. thanks for pointing out.Rahul– Rahul2016-06-20 05:37:23 +00:00Commented Jun 20, 2016 at 5:37
-
@TwitchedOut see my updates and try again with new repos.Rahul– Rahul2016-06-20 05:44:08 +00:00Commented Jun 20, 2016 at 5:44
Red Hat has been working on a set of repositories called Software Collections (SCL). CentOS 7 includes a similar set of repositories which make it easier to install PHP 5.6, 7.1, and other things not available in the base repositories. I also recommend using EPEL and if you haven't changed defaults, it's as easy as:
yum install epel-release
yum install centos-release-scl
Now you should have access to all of the EPEL and SCL packages. To install PHP 7.1, you can simply
yum install rh-php71
It will add the packages to /opt/rh/rh-php71/root/*, but the php.ini configuration will reside in /etc/opt/rh/rh-php71/. To make the newly installed version of PHP the default PHP used from the command line, you can add to a file in /etc/profile.d/ :
printf '#!/bin/bash\nsource scl_source enable rh-php71\n' > /etc/profile.d/php71.sh ; chmod ugo+r /etc/profile.d/php71.sh
The process is similar for PHP 5.6. All of the other pre-built packages for PHP 7.1 can be found with:
yum search php71
More information about the EPEL and SCL repositories can be found here:
https://fedoraproject.org/wiki/EPEL
https://wiki.centos.org/AdditionalResources/Repositories/SCL