Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I found some blog posts about this, but it's rather lack of descriptions on possible side effects.

I could really use some detailed on these steps:

  1. How to add a repo that provides PHP 5.4 into yum
  2. Can this seamlessly replaces the current PHP version in CentOS?
  3. How can I switch back to the official repo when it supports PHP 5.4? (current 5.3.3 in my system)
  4. Will there be any potential to break PHP modules I currently using?

Note

People successfully upgraded with the same method on newer versions, and suggest removing specific versions in the question. While it is good to pin down versions in case newer versions actually breaks something, I'd like keep the latest succeed version suggested by the community as a note.

Feel free to update this if you have successfully upgraded on other versions.

  • PHP versions: 5.4, 5.5
  • CentOS version: 6
share|improve this question
add comment

3 Answers

up vote 13 down vote accepted

I followed the instructions from Install Apache/PHP 5.4.10 on Fedora 17/16, CentOS/RHEL 6.3/5.8 with a slight modification. It took maybe 10min. My exact commands are shown below. Note that the first command had to be changed from what is shown in the article. The change was from epel-release-6-7.noarch.rpm to epel-release-6-8.noarch.rpm.

  1. How to add a repo that provides PHP 5.4 into yum?

    rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
    rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
    
  2. Can this seamlessly replace the current PHP version in CentOS? For me the following commands worked and none of my existing PHP web pages broke. Your mileage may vary.

    yum --enablerepo=remi,remi-test install httpd php php-common
    yum --enablerepo=remi,remi-test install php-pecl-apc php-cli php-pear php-pdo php-mysql php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml
    service httpd restart
    
  3. How can I switch back to the official repo when it supports PHP5.4? I have not tested the commands to remove and re-install PHP from CentOS repositories, but these should work.

    # Remove the Remi packages. Note the reversed command order
    yum remove php-pecl-apc php-cli php-pear php-pdo php-mysql php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml
    yum  remove httpd php php-common
    # Install the CentOS packages. 
    yum install httpd php php-common
    yum install php-pecl-apc php-cli php-pear php-pdo php-mysql php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml
    
  4. Will there be any potential to break PHP modules I [sic] currently using? Yes. Using a recent version of CentOS (6.2?) with Zend installed using the Zend installer, the above upgrade broke Zend.

All the above commands were run as root. Best practice is to login as a non-privileged user and use sudo. (This is a development VM with a current snapshot...)

Also, do NOT enable the Remi repository by default - in the past I got clever and enabled it by default and things broke, even with repository priority.

share|improve this answer
3  
Things often get ugly with remi. I prefer to use iuscommunity repository for up-to-date php. Another way is to use Zend server repo, but it seems a bit overhead for me. –  Kazimieras Aliulis Dec 28 '12 at 12:40
1  
@KazimierasAliulis Unfortunately the IUS repo induces dependency hell by using incompatible package and file names. I can't recommend using it. –  Michael Hampton Dec 28 '12 at 19:30
    
Very thorough description. Since I have no code related to Zend engine, it shouldn't matter in my case, right? –  Vicary Jan 2 '13 at 5:55
    
@Vicary It depends on what third-party libraries/frameworks you are using. Generally, this is a conservative update so you should be pretty safe. –  Jeff Benshetler Jan 15 '13 at 14:49
    
@MichaelHampton I use yum --enablerepo=remi update and it takes care of all related php packages, looks like a better solution. The server runs without problems for some days now, thanks for all the info. –  Vicary Jan 16 '13 at 11:17
show 4 more comments

you can find php 5.4.9 here for the yum install:

http://www.webtatic.com/packages/php54/

you can do a "rpm -qa | grep php" to see all your current php packages and a "rpm -e" to remove. i don't know your current modules, but it's worth testing before the upgrade.

share|improve this answer
    
You kinda answered 1. When it comes to server maintenance, it is not simply installing it and run tests, I could really use more info before doing anything. –  Vicary Dec 16 '12 at 8:55
add comment

An improvement over the other Webtatic answer:

1 . Using the guide on http://www.webtatic.com/packages/php54/:

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

2 . You need to first see what existing installed packages need replacing, you can do this by using yum shell to combine removing php-common and installing php54w-common in one transaction (so shared dependencies aren't removed)

yum shell
> remove php-common
> install php54w-common
> run
…
Is this ok [y/N]: n

Don't say "y" to the results, but take note of all packages mentioned in "Removing for dependencies", e.g.

Removing for dependencies:
 php
 php-cli
 php-pear
 php-pecl-memcache
 php-mysql

If there are other packages than php* in this list then you can't seamlessly switch to Webtatic PHP 5.4, but will have to investigate alternatives. Webtatic has replacement packages for all base php packages (see the packages listed on the page linked to in 1. for confirmation), so there should be no issues, unless you use other 3rd party repositories that have packages installed dependent on the specific php version installed.

For the rest of the installation (still in yum shell), you just remove these packages and install their php54w-* counterparts:

> remove php-common php php-cli php-pear php-pecl-memcache php-mysql
> install php54w-common php54w php54w-cli php54w-pear php54w-pecl-memcache php54w-mysql
> run
…
Is this ok [y/N]: y

You should then only see the packages you've set to be removed and installed in the list, and you can confirm the installation to switch over. Any services currently running with php loaded will need to be restarted, for instance httpd or php-fpm.

As for this being 'seamless', any software changes happening while users are able to access the website should have the consequences fully understood. Shared libraries being removed and added when a process hasn't already loaded them could potentially load while the shared library isn't there. It's better to do software upgrades like this offline, and preferably tested on a non-production machine first to verify the process works as expected.

3 . To switch to a hypothetical CentOS base php54 package (CentOS 5 used php53 prefix), you just run the above steps replacing php removal with php54w removal, and php54w installation with php54 installation e.g.

yum shell
> remove php54w-common
> install php54-common
> run
…
Is this ok [y/N]: n
…
> remove php54w-common php54w php54w-cli php54w-pear php54w-pecl-memcache php54w-mysql
> install php54-common php54 php54-cli php54-pear php54-pecl-memcache php54-mysql
> run
Is this ok [y/N]: y

However as for the switch to the hypothetical base php54, there will likely be no alternatives for some packages (e.g. there was no php53-pecl-memcache extension in CentOS 5) and Webtatic has packages that aren't available in CentOS base (e.g. php54w-pecl-zendopcache). If they are missing, then you usually don't have any other option than to use pecl directly to install them.

4 . Any PHP upgrade may introduce bugs, and websites should be retested. This is not specific to Webtatic, but the general idea that new features introduce new bugs.

Unlike Remi's repository in the accepted answer, the Webtatic EL6 repository never uses the same package names as CentOS base repositories, so will not override installation/upgrade of packages you don't intend to switch to, and as such is enabled by default.

Disclaimer: I'm the owner/maintainer of Webtatic

share|improve this answer
    
The yum shell method is really good for dependancy observing, thanks. –  Vicary May 20 '13 at 4:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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