Upgrading PHP on CentOS 6.5 (Final)
Asked Answered
B

7

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

Barbiturate answered 1/2, 2014 at 19:41 Comment(6)
What command are you entering to update your version of PHP?Kemper
yum update php, I've tried a few thoughBarbiturate
Try yum update and see what packages yum marks for updateKemper
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 UpdateBarbiturate
Try following these instructions. It looks like CentOS hasn't added 5.5.8 to their base repository yet: if-not-true-then-false.com/2010/…Kemper
Good guide for upgrading to php7 - tecmint.com/install-php-7-in-centos-6Zygapophysis
P
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)

Priedieu answered 22/6, 2014 at 12:38 Comment(16)
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.rpmParenthesis
See also shayanderson.com/linux/… (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]).Parenthesis
I get no Package php54w error. I actually get the same error for 55 and 56 too. Any idea how I can fix that?Mizzen
as for centOs 7, here you go http://mirror.webtatic.com/yum/el7/epel-release.rpmPistoia
That didn't work at all for me on CentoOS 6.6. Luckely I made a snapshot before!Goldeneye
I ran into the same problem with the conflict on CentOS 6.0 64bit, however running yum install php54w-mysql fixed the problem.Delatorre
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!Photoelectric
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?Photoelectric
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?Priedieu
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.Bogus
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.Counterglow
This worked for me. I have been trying 100s of different solutions, finally I found yours. Thanks!Yance
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.Odaodab
just wanted to point out that the repo suggested in this answer (webatic) is not recommended by the centos community wiki (see: wiki.centos.org/AdditionalResources/Repositories). They say " IUS or SCL are better alternatives."Thales
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. ;-)Priedieu
for soap: yum install php56w-soapSainfoin
T
28

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.

Theretofore answered 1/2, 2014 at 20:44 Comment(4)
webtatic.com also offers php 5.5/5.4 by installing this rpm. rpm -Uvh mirror.webtatic.com/yum/el6/latest.rpmKai
As a newcomer to CentOS, how do I know these repos are trustworthy?Sedate
@Sedate 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.Theretofore
@JacobBudin True, but I think healthy skepticism of unofficial repos is a good thingMellifluous
F
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.

Fogged answered 30/1, 2015 at 13:56 Comment(2)
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 phpPanda
Piping a web page to a shell script is almost always bad security.Subversive
S
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

Sibella answered 28/12, 2016 at 4:59 Comment(3)
I get Error: php56u conflicts with php-5.4.16-42.el7.x86_64Miran
Quite a bit of time later since this answer, but I see epel-release-latest-7.noarch.rpm is downloaded, but is it installed?Mellifluous
To install use rpm -Uvh ius-release*.rpmSibella
O
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
Orangeman answered 30/8, 2016 at 17:19 Comment(0)
V
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
Vaca answered 18/4, 2016 at 19:3 Comment(0)
Z
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 
Zygapophysis answered 20/12, 2018 at 23:29 Comment(2)
I feel like this has been pretty well covered in other answers over the past 5 years.Aikens
The above answers don't include steps for upgrading CentOS 6 to PHP 7. So I have added an answer for this.Zygapophysis

© 2022 - 2024 — McMap. All rights reserved.