# 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) ?
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
You can use remi like Michael Hampton suggested, but for sake of completeness, you can also compile your own php.
You'll need basic development tools, and you should be able to get that through a group install.
yum groupinstall "Development Tools"
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.
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.
# 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
# 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
# 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