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.
# cat /etc/redhat-release
  CentOS release 6.3 (Final)

# php -v
  PHP 5.3.3

# yum update php
  No Packages marked for Update

How do I upgrade to the latest version PHP 5.4.10 (Current stable) ?

share|improve this question
    
Unless you need to, generally you don't. –  Ignacio Vazquez-Abrams Jan 12 '13 at 6:13
    
@IgnacioVazquez-Abrams I need too, there is a core defect that is affecting the development of an application. –  Dan Kanze Jan 12 '13 at 6:15
add comment

3 Answers

up vote 9 down vote accepted

You can use the remi repository, which provides PHP 5.4 as well as MySQL 5.5 and some other LAMP related stuff not available with CentOS base or EPEL. If you use this repository, I strongly recommend the yum-versionlock plugin to ensure that your version of PHP remains on the 5.4 branch.

share|improve this answer
    
yum-versionlock plugin is used too force point to the remi repo so when I yum update php I am not overiding current version? –  Dan Kanze Jan 12 '13 at 6:22
1  
You would use it to ensure that you remain on 5.4, and don't unexpectedly get 5.5 after it hits release a few months from now. –  Michael Hampton Jan 12 '13 at 6:24
add comment

You can use remi like Michael Hampton suggested, but for sake of completeness, you can also compile your own php.

Download

You can download the latest version of php 5.4.10 from here. Or in the event that my link is outdated by the time someone else sees this, you can go to main php download page and navigate as well.

Dev Tools

You'll need basic development tools, and you should be able to get that through a group install.

yum groupinstall "Development Tools"

Required Libraries

You'll also need bunch of libraries to compile PHP. The following is a mere sample list. You may need to adjust depending on additional modules you are installing.

yum install libxml2-devel httpd-devel libXpm-devel gmp-devel libicu-devel \
    t1lib-devel aspell-devel openssl-devel bzip2-devel libcurl-devel \
    libjpeg-devel libvpx-devel libpng-devel freetype-devel readline-devel \
    libtidy-devel libxslt-devel

Another common library often used is mcrypt (libmcrypt-devel), but that's available under rpmforge and not the base.

Compiling

Once all the requirements are set, actual compilation is fairly simple.

Extract the php you downloaded earlier and enter directory.

tar jxf php-5.4.*.tar.bz2
cd php-5.4.10

Configure the PHP with stuff you want enabled.

./configure --enable-zip --[etc. This list can get pretty long...]

You can see a full list of PHP configuration options here.

Then finalize with build.

make
make install

Now you have php 5.4.* on your Centos 6.

share|improve this answer
add comment

Remi Dependency on CentOS 6 and Red Hat (RHEL) 6:

# rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

CentOS 6 and Red Hat (RHEL) 6:

# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

Update your PHP:

# yum --enablerepo=remi,remi-test install httpd php php-common

CentOS 6.3/6.2/6.1/6/5.8 and Red Hat (RHEL) 6.3/6.2/6.1/6/5.8

Update your modules:

# 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

http://www.if-not-true-then-false.com/2010/install-apache-php-on-fedora-centos-red-hat-rhel/

share|improve this answer
2  
If this is for a production machine I'd strongly recommend that remi-test is not enabled. –  John Gardeniers Jan 12 '13 at 7:55
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.