When I run yum install php php-devel php-mysql php-gd php-mbstring, it will install php5.3.

yum list installed *php*
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: ftp.tsukuba.wide.ad.jp
 * epel: ftp.kddilabs.jp
 * extras: ftp.tsukuba.wide.ad.jp
 * updates: ftp.tsukuba.wide.ad.jp
Installed Packages
php.x86_64                       5.3.3-46.el6_6               @updates
php-cli.x86_64                   5.3.3-46.el6_6               @updates
php-common.x86_64                5.3.3-46.el6_6               @updates
php-devel.x86_64                 5.3.3-46.el6_6               @updates
php-gd.x86_64                    5.3.3-46.el6_6               @updates
php-mbstring.x86_64              5.3.3-46.el6_6               @updates
php-mysql.x86_64                 5.3.3-46.el6_6               @updates
php-pdo.x86_64                   5.3.3-46.el6_6               @updates

I just removed it yum remove php php-cli php-common php-devel php-gd php-mbstring php-mysql php-pdo.

And I tried yum install php56w php56w-devel php56w-mysql php56w-gd php56w-mbstring, but they are not available.

Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: ftp.tsukuba.wide.ad.jp
 * epel: ftp.kddilabs.jp
 * extras: ftp.tsukuba.wide.ad.jp
 * updates: ftp.tsukuba.wide.ad.jp
No package php56w available.
No package php56w-devel available.
No package php56w-mysql available.
No package php56w-gd available.
No package php56w-mbstring available.
Error: Nothing to do

How can I install php5.6 on CentOS 6?


you would add repo into centos 6 by:

rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm


#yum clean all
#yum install php56w php56w-common

I hope help you!


CentOS now offers Software Collections (SCL) as a repo installable from base:

yum install centos-release-scl

Once you've installed the SCL repo, you can install php 5.6:

yum install rh-php56

The CentOS documentation is slightly dated as is the Red Hat Documentation, but newer versions of php, PostgreSQL, MariaDB, MySQL, perl, ruby, etc. are available. It's also available on CentOS and RHEL 7 and is theoretically better integrated with the OS. The notes say that adding packages through SCL won't interfere with the system's utilities, such as yum.

To make the SCL version of PHP the default on the command line, run the following as root to add to the default profile:

printf '#!/bin/bash\nsource scl_source enable rh-php56\n' > /etc/profile.d/php56.sh
chmod ugo+r /etc/profile.d/php56.sh

This makes using pear to add PHP packages easier by setting $PATH to include /opt/rh/rh-php56/root/...

  • are those safe and new? Centos repos always very old.
    – nerkn
    Dec 28 '17 at 22:58
  • It's the official CentOS SCL repo for CentOS, so I'd say it's as safe as the rest of CentOS. It's certainly safer than some other repositories because it won't interfere with of the other CentOS update repos or system packages. If you're using something that's not CentOS, these instructions aren't for you.
    – Liczyrzepa
    Jan 3 '18 at 22:48
  • centos-release-scl is x86_64 only May 17 '19 at 18:30

You can use REMI's repository

To enable it, follow these steps:

  1. yum install http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
  2. edit /etc/yum.repos.d/remi.repo and, under then [remi-php56] tag, set enabled=1
  3. yum install php

Please note that, doing that, you will update the system-wide php package to the 5.6 version. If you need, for some reason, install PHP 5.6 alongside the older, CentOS-distributed relase, you had to do a more complex side-by-side installation.

  • 4
    Instead of 2, simply use: yum-config-manager --enable remi-php56 Oct 29 '15 at 14:23

Try installing from specific repo

yum --disablerepo="*" --enablerepo="remi-php56" install php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.