65

I'm trying to update my PHP (currently v:5.3.3 to the latest stable PHP build) but it's not playing ball and it's saying there is nothing to update.

Any help would be useful.

Keeps saying:

No Packages marked for Update

BCLtd
  • 1,459
  • 2
  • 18
  • 45
  • What command are you entering to update your version of PHP? – Mike Koch Feb 01 '14 at 20:00
  • yum update php, I've tried a few though – BCLtd Feb 01 '14 at 20:21
  • 1
    Try `yum update` and see what packages yum marks for update – Mike Koch Feb 01 '14 at 20:32
  • it displays: Loaded plugins: fastestmirror, replace Loading mirror speeds from cached hostfile * base: centos.mirror.triple-it.nl * epel: nl.mirror.eurid.eu * extras: centos.mirror.triple-it.nl * updates: centos.mirror.triple-it.nl * webtatic-el5: nl.repo.webtatic.com Setting up Update Process No Packages marked for Update – BCLtd Feb 01 '14 at 20:33
  • 1
    Try following these instructions. It looks like CentOS hasn't added 5.5.8 to their base repository yet: http://www.if-not-true-then-false.com/2010/install-apache-php-on-fedora-centos-red-hat-rhel/ – Mike Koch Feb 01 '14 at 20:38
  • Good guide for upgrading to php7 - https://www.tecmint.com/install-php-7-in-centos-6/ – SyntaxGoonoo Dec 20 '18 at 23:20

7 Answers7

123

As Jacob mentioned, the CentOS packages repo appears to only have PHP 5.3 available at the moment. But these commands seemed to work for me...

rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
yum remove php-common       # Need to remove this, otherwise it conflicts
yum install php56w
yum install php56w-mysql
yum install php56w-common
yum install php56w-pdo
yum install php56w-opcache
php --version               # Verify version has been upgraded

You can alternatively use php54w or php55w if required.

CAUTION!
This may potentially break your website if it doesn't fully resolve all your dependencies, so you may need a couple of extra packages in some cases. See here for a list of other PHP 5.6 modules that are available.

If you encounter a problem and need to reset back to the default, you can use these commands:

sudo yum remove php56w
sudo yum remove php56w-common
sudo yum install php-common
sudo yum install php-mysql
sudo yum install php

(Thanks Fabrizio Bartolomucci)

Simon East
  • 55,742
  • 17
  • 139
  • 133
  • 5
    In case anyone else out there needs to do this upgrade on CentOS 5, use this command instead: `rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm` – Matt Browne Oct 25 '14 at 21:07
  • See also http://www.shayanderson.com/linux/centos-5-or-centos-6-upgrade-php-to-php-54-or-php-55.htm (and note that you can leave off the `.x86_64` suffixes from the package names; it will default to your current architecture [which might be i386, not x86_64]). – Matt Browne Oct 25 '14 at 21:10
  • 1
    I get `no Package php54w` error. I actually get the same error for 55 and 56 too. Any idea how I can fix that? – TMH Nov 10 '14 at 13:03
  • 2
    as for centOs 7, here you go `http://mirror.webtatic.com/yum/el7/epel-release.rpm` – Muhaimin Dec 30 '14 at 18:22
  • 1
    That didn't work at all for me on CentoOS 6.6. Luckely I made a snapshot before! – Timo002 Feb 02 '15 at 23:08
  • I ran into the same problem with the conflict on CentOS 6.0 64bit, however running `yum install php54w-mysql` fixed the problem. – TheRealJAG Mar 31 '15 at 01:54
  • Downvoting because this mirror is no longer valid; webtactic.com now points to a parked domain. EDIT: It appears they have a broken redirect; it's all https now. Please update your links! – Sean Werkema Jun 07 '15 at 23:32
  • No, it's a broken URL; https requests time out, and http redirects to a parked domain. There's something seriously wrong with webtactic.com. Do you know of any other valid mirrors? – Sean Werkema Jun 07 '15 at 23:38
  • Hi @SeanWerkema - I've just tested in my browser and both webtatic.com and mirror.webtatic.com seem to still be available. Can you retest? – Simon East Jun 08 '15 at 04:05
  • I made the mistake of thinking that the folder in the URL named "el6" had a number one in it, as opposed to the letter "l". Make sure you are entering a letter "l" and not "1". That worked for me. – Lucha Laura Hardie Oct 07 '15 at 18:26
  • So apparently my edit was rejected for no apparent reason. So if in any case your yum installation fails to reference the webtatic repo which in my case did you can call the repo again by appending `--enablerepo=webtatic`. – djowinz Mar 22 '16 at 00:28
  • This worked for me. I have been trying 100s of different solutions, finally I found yours. Thanks! – Miguel Tavares Apr 24 '16 at 01:58
  • This is good information but everyone should use caution as unfortunately a lot of functions have been deprecated as you move to newer PHP versions. This could mean without thorough testing that you break your application and will only find out the hard way later on. At the very minimum a test-plan should be made and error logs should be watched for functions that do not exist anymore. – Areeb Soo Yasir Jan 16 '17 at 07:25
  • 2
    just wanted to point out that the repo suggested in this answer (webatic) is not recommended by the centos community wiki (see: https://wiki.centos.org/AdditionalResources/Repositories). They say " IUS or SCL are better alternatives." – Ruben Estrada Aug 19 '17 at 17:25
  • Thanks @RubenEstrada - feel free to edit my answer with the necessary commands to use the better repos - preferably well-tested to ensure they work as expected. ;-) – Simon East Aug 20 '17 at 22:17
  • for soap: yum install php56w-soap – Phyllis Sutherland Mar 18 '18 at 16:16
29

For CentOS 6, PHP 5.3.3 is the latest version of PHP available through the official CentOS package repository. Keep in mind, even though PHP 5.3.3 was released July 22, 2010, the official CentOS 6 PHP package was updated November 24, 2013. Why? Critical bug fixes are backported. See this question for more information: "Why are outdated packages installed by yum on CentOS? (specifically PHP 5.1) How to fix?"

If you'd like to use a more recent version of PHP, Les RPM de Remi offers CentOS PHP packages via a repository that you can add to the yum package manager. To add it as a yum repository, follow the site's instructions.

Note: Questions of this variety are probably better suited for Server Fault.

Community
  • 1
  • 1
Jacob Budin
  • 9,753
  • 4
  • 32
  • 35
  • 1
    webtatic.com also offers php 5.5/5.4 by installing this rpm. rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm – jbrahy Mar 20 '14 at 18:55
  • 5
    As a newcomer to CentOS, how do I know these repos are trustworthy? – Liam Oct 30 '14 at 16:35
  • 3
    @Liam Practically speaking, you cannot be assured any software is trustworthy. In this case, if you believe the PHP source code is trustworthy but this respository may not be, you can compile the products yourself (in the same manner as the repository owner) and compare the hashes (e.g., with `sha1sum`) to see whether they are equal. – Jacob Budin Nov 11 '14 at 02:16
  • @JacobBudin True, but I think healthy skepticism of unofficial repos is a good thing – Robert Dundon Jun 07 '18 at 17:38
8

I managed to install php54w according to Simon's suggestion, but then my sites stopped working perhaps because of an incompatibility with php-mysql or some other module. Even frantically restoring the old situation was not amusing: for anyone in my own situation the sequence is:

sudo yum remove php54w
sudo yum remove php54w-common
sudo yum install php-common
sudo yum install php-mysql
sudo yum install php

It would be nice if someone submitted the full procedure to update all the php packet. That was my production server and my heart is still rapidly beating.

  • if you'd like to upgrade php on a LAMP server without any problems try this: `wget -q -O - http://www.atomicorp.com/installers/atomic | sh` and the run `yum update php` – Dmitry Jun 25 '15 at 09:56
  • 1
    Piping a web page to a shell script is almost always bad security. – Kzqai Sep 30 '16 at 16:39
6

This is the easiest way that worked for me: To install PHP 5.6 on CentOS 6 or 7:

CentOS 6. Enter the following commands in the order shown:

yum -y update
yum -y install epel-release
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
wget https://centos6.iuscommunity.org/ius-release.rpm
rpm -Uvh ius-release*.rpm
yum -y update
yum -y install php56u php56u-opcache php56u-xml php56u-mcrypt php56u-gd php56u-devel php56u-mysql php56u-intl php56u-mbstring php56u-bcmath

CentOS 7. Enter the following commands in the order shown:

yum -y update
yum -y install epel-release
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget https://centos7.iuscommunity.org/ius-release.rpm
rpm -Uvh ius-release*.rpm
yum -y update
yum -y install php56u php56u-opcache php56u-xml php56u-mcrypt php56u-gd php56u-devel php56u-mysql php56u-intl php56u-mbstring php56u-bcmath

Sorry - I'm unable to post the source URL - due to reputation

Muhammad Hassaan
  • 7,296
  • 6
  • 30
  • 50
Bonfix Ngetich
  • 1,087
  • 11
  • 15
4
  1. Verify current version of PHP Type in the following to see the current PHP version:

    php -v

    Should output something like:

    PHP 5.3.3 (cli) (built: Jul 9 2015 17:39:00) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

  2. Install the Remi and EPEL RPM repositories

If you haven’t already done so, install the Remi and EPEL repositories

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm && rpm -Uvh epel-release-latest-6.noarch.rpm



wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm && rpm -Uvh remi-release-6*.rpm

Enable the REMI repository globally:

nano /etc/yum.repos.d/remi.repo

Under the section that looks like [remi] make the following changes:

[remi]
name=Remi's RPM repository for Enterprise Linux 6 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/6/remi/$basearch/
mirrorlist=http://rpms.remirepo.net/enterprise/6/remi/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

Also, under the section that looks like [remi-php55] make the following changes:

[remi-php56]
name=Remi's PHP 5.6 RPM repository for Enterprise Linux 6 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/6/php56/$basearch/
mirrorlist=http://rpms.remirepo.net/enterprise/6/php56/mirror
# WARNING: If you enable this repository, you must also enable "remi"
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

Type CTRL-O to save and CTRL-X to close the editor

  1. Upgrade PHP 5.3 to PHP 5.6 Now we can upgrade PHP. Simply type in the following command:

    yum -y upgrade php*

Once the update has completed, let’s verify that you have PHP 5.6 installed:

php -v

Should see output similar to the following:

PHP 5.6.14 (cli) (built: Sep 30 2015 14:07:43) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
Mere Development
  • 2,439
  • 5
  • 32
  • 63
Fuad Fouad
  • 448
  • 3
  • 9
1

IUS offers an installation script for subscribing to their repository and importing associated GPG keys. Make sure you’re in your home directory, and retrieve the script using curl:

curl 'https://setup.ius.io/' -o setup-ius.sh
sudo bash setup-ius.sh

Install Required Packages-:

sudo yum install -y mod_php70u php70u-cli php70u-mysqlnd php70u-json php70u-gd php70u-dom php70u-simplexml php70u-mcrypt php70u-intl
miken32
  • 42,008
  • 16
  • 111
  • 154
1

Steps for upgrading to PHP7 on CentOS 6 system. Taken from install-php-7-in-centos-6

To install latest PHP 7, you need to add EPEL and Remi repository to your CentOS 6 system

yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
yum install http://rpms.remirepo.net/enterprise/remi-release-6.rpm

Now install yum-utils, a group of useful tools that enhance yum’s default package management features

yum install yum-utils

In this step, you need to enable Remi repository using yum-config-manager utility, as the default repository for installing PHP.

yum-config-manager --enable remi-php70

If you want to install PHP 7.1 or PHP 7.2 on CentOS 6, just enable it as shown.

yum-config-manager --enable remi-php71 
yum-config-manager --enable remi-php72

Then finally install PHP 7 on CentOS 6 with all necessary PHP modules using the following command.

yum install php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo

Double check the installed version of PHP on your system as follows.

php -V 
SyntaxGoonoo
  • 900
  • 8
  • 10