Upgrade/update php to latest 5.2.17 in Linux

by jagbir on July 28, 2011

In a CentOS 5.5 host, we were required to upgrade php to its latest release which is 5.2.17 when writing this article. Again there are various options to do such upgrade and trying to install with the package manager (yum) is just one (aka easy) of them. You can also trying downloading latest source code and compile yourself to have better control but for ease of use, I’m updating php with yum here.

Again, you won’t find the latest PHP binaries in default repositories available with CentOS and to resolve that we need to have CentAlt repo (or other such repos like epel).

Here are quick steps:

Step 1. Create repo file in /etc/yum.repos.d directory:

$ vi /etc/yum.repos.d/centalt.repo
[CentALT]
name=CentALT Packages for Enterprise Linux 5 - $basearch
baseurl=http://centos.alt.ru/repository/centos/5/$basearch/
enabled=1
gpgcheck=0

RELATED: Upgrade PHP to its latest version by manual compiling its source code.

Step 2. When I tried updating PHP, ran in an issue of “Error: Missing Dependency: libt1.so.5 is needed by package php-gd-5.2.17-1.el5.i386″. Complete details below:

$ yum update php
Loaded plugins: fastestmirror
Determining fastest mirrors
CentALT                                                                                                                             |  951 B     00:00     
CentALT/primary                                                                                                                     |  90 kB     00:01     
CentALT                                                                                                                                            258/258
addons                                                                                                                              |  951 B     00:00     
addons/primary                                                                                                                      |  202 B     00:00     
base                                                                                                                                | 2.1 kB     00:00     
base/primary_db                                                                                                                     | 1.6 MB     00:00     
extras                                                                                                                              | 2.1 kB     00:00     
extras/primary_db                                                                                                                   | 188 kB     00:00     
turbopanel-base                                                                                                                     |  951 B     00:00     
turbopanel-base/primary                                                                                                             |  83 kB     00:00     
turbopanel-base                                                                                                                                    560/560
turbopanel-centos5                                                                                                                  |  951 B     00:00     
turbopanel-centos5/primary                                                                                                          | 2.5 kB     00:00     
turbopanel-centos5                                                                                                                                   10/10
update                                                                                                                              | 1.9 kB     00:00     
update/primary_db                                                                                                                   | 889 kB     00:00     
Setting up Update Process
Resolving Dependencies
--> Running transaction check
---> Package php.i386 0:5.2.17-1.el5 set to be updated
---> Package php-cli.i386 0:5.2.17-1.el5 set to be updated
--> Processing Dependency: libevent-1.4.so.2 for package: php-cli
---> Package php-common.i386 0:5.2.17-1.el5 set to be updated
---> Package php-devel.i386 0:5.2.17-1.el5 set to be updated
---> Package php-gd.i386 0:5.2.17-1.el5 set to be updated
--> Processing Dependency: libt1.so.5 for package: php-gd
---> Package php-imap.i386 0:5.2.17-1.el5 set to be updated
---> Package php-ldap.i386 0:5.2.17-1.el5 set to be updated
---> Package php-mbstring.i386 0:5.2.17-1.el5 set to be updated
---> Package php-mysql.i386 0:5.2.17-1.el5 set to be updated
---> Package php-ncurses.i386 0:5.2.17-1.el5 set to be updated
---> Package php-odbc.i386 0:5.2.17-1.el5 set to be updated
---> Package php-pdo.i386 0:5.2.17-1.el5 set to be updated
---> Package php-pear.noarch 1:1.9.1-1.el5 set to be updated
---> Package php-pgsql.i386 0:5.2.17-1.el5 set to be updated
---> Package php-snmp.i386 0:5.2.17-1.el5 set to be updated
---> Package php-xml.i386 0:5.2.17-1.el5 set to be updated
---> Package php-xmlrpc.i386 0:5.2.17-1.el5 set to be updated
--> Running transaction check
---> Package libevent.i386 0:1.4.13-1 set to be updated
---> Package php-gd.i386 0:5.2.17-1.el5 set to be updated
--> Processing Dependency: libt1.so.5 for package: php-gd
--> Finished Dependency Resolution
php-gd-5.2.17-1.el5.i386 from CentALT has depsolving problems
  --> Missing Dependency: libt1.so.5 is needed by package php-gd-5.2.17-1.el5.i386 (CentALT)
Error: Missing Dependency: libt1.so.5 is needed by package php-gd-5.2.17-1.el5.i386 (CentALT)
 You could try using --skip-broken to work around the problem
 You could try running: package-cleanup --problems
                        package-cleanup --dupes
                        rpm -Va --nofiles --nodigest
The program package-cleanup is found in the yum-utils package.

Step 3. To resolve the issue, we need to have t1lib package, so install it now:

$ yum install t1lib* --nogpgcheck
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
addons                                                                                                                              |  951 B     00:00     
base                                                                                                                                | 2.1 kB     00:00     
extras                                                                                                                              | 2.1 kB     00:00     
update                                                                                                                              | 1.9 kB     00:00     
Setting up Install Process
Examining t1lib-5.1.2-1.el5.rf.i386.rpm: t1lib-5.1.2-1.el5.rf.i386
Marking t1lib-5.1.2-1.el5.rf.i386.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package t1lib.i386 0:5.1.2-1.el5.rf set to be updated
--> Processing Dependency: libICE.so.6 for package: t1lib
--> Processing Dependency: libSM.so.6 for package: t1lib
--> Processing Dependency: libXaw.so.7 for package: t1lib
--> Processing Dependency: libXext.so.6 for package: t1lib
--> Processing Dependency: libXmu.so.6 for package: t1lib
--> Processing Dependency: libXt.so.6 for package: t1lib
--> Running transaction check
---> Package libICE.i386 0:1.0.1-2.1 set to be updated
---> Package libSM.i386 0:1.0.1-3.1 set to be updated
---> Package libXaw.i386 0:1.0.2-8.1 set to be updated
---> Package libXext.i386 0:1.0.1-2.1 set to be updated
---> Package libXmu.i386 0:1.0.2-5 set to be updated
---> Package libXt.i386 0:1.0.2-3.2.el5 set to be updated
--> Finished Dependency Resolution
 
Dependencies Resolved
 
===========================================================================================================================================================
 Package                        Arch                        Version                                Repository                                         Size
===========================================================================================================================================================
Installing:
 t1lib                          i386                        5.1.2-1.el5.rf                         /t1lib-5.1.2-1.el5.rf.i386                        854 k
Installing for dependencies:
 libICE                         i386                        1.0.1-2.1                              base                                               54 k
 libSM                          i386                        1.0.1-3.1                              base                                               27 k
 libXaw                         i386                        1.0.2-8.1                              base                                              324 k
 libXext                        i386                        1.0.1-2.1                              base                                               35 k
 libXmu                         i386                        1.0.2-5                                base                                               62 k
 libXt                          i386                        1.0.2-3.2.el5                          base                                              173 k
 
Transaction Summary
===========================================================================================================================================================
Install       7 Package(s)
Upgrade       0 Package(s)
 
Total size: 1.5 M
Is this ok [y/N]: y
...
...
Installed:
  t1lib.i386 0:5.1.2-1.el5.rf

Step 4. Trying again now to update PHP should go smooth:

$ yum update php
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
addons                                                                                                                              |  951 B     00:00     
base                                                                                                                                | 2.1 kB     00:00     
extras                                                                                                                              | 2.1 kB     00:00     
update                                                                                                                              | 1.9 kB     00:00     
Setting up Update Process
Resolving Dependencies
--> Running transaction check
--> Processing Dependency: php = 5.1.6-27.el5 for package: php-devel
---> Package php.i386 0:5.2.17-1.el5 set to be updated
--> Processing Dependency: php-common = 5.2.17-1.el5 for package: php
--> Processing Dependency: php-cli = 5.2.17-1.el5 for package: php
--> Running transaction check
---> Package php-cli.i386 0:5.2.17-1.el5 set to be updated
--> Processing Dependency: libevent-1.4.so.2 for package: php-cli
--> Processing Dependency: php-common = 5.1.6-27.el5 for package: php-gd
--> Processing Dependency: php-common = 5.1.6-27.el5 for package: php-xml
--> Processing Dependency: php-common = 5.1.6-27.el5 for package: php-imap
--> Processing Dependency: php-common = 5.1.6-27.el5 for package: php-pgsql
--> Processing Dependency: php-common = 5.1.6-27.el5 for package: php-mysql
--> Processing Dependency: php-common = 5.1.6-27.el5 for package: php-xmlrpc
--> Processing Dependency: php-common = 5.1.6-27.el5 for package: php-ncurses
--> Processing Dependency: php-common = 5.1.6-27.el5 for package: php-pdo
--> Processing Dependency: php-common = 5.1.6-27.el5 for package: php-mbstring
--> Processing Dependency: php-common = 5.1.6-27.el5 for package: php-odbc
--> Processing Dependency: php-common = 5.1.6-27.el5 for package: php-snmp
--> Processing Dependency: php-common = 5.1.6-27.el5 for package: php-ldap
---> Package php-common.i386 0:5.2.17-1.el5 set to be updated
---> Package php-devel.i386 0:5.2.17-1.el5 set to be updated
--> Running transaction check
---> Package libevent.i386 0:1.4.13-1 set to be updated
---> Package php-gd.i386 0:5.2.17-1.el5 set to be updated
---> Package php-imap.i386 0:5.2.17-1.el5 set to be updated
---> Package php-ldap.i386 0:5.2.17-1.el5 set to be updated
---> Package php-mbstring.i386 0:5.2.17-1.el5 set to be updated
---> Package php-mysql.i386 0:5.2.17-1.el5 set to be updated
---> Package php-ncurses.i386 0:5.2.17-1.el5 set to be updated
---> Package php-odbc.i386 0:5.2.17-1.el5 set to be updated
---> Package php-pdo.i386 0:5.2.17-1.el5 set to be updated
---> Package php-pgsql.i386 0:5.2.17-1.el5 set to be updated
---> Package php-snmp.i386 0:5.2.17-1.el5 set to be updated
---> Package php-xml.i386 0:5.2.17-1.el5 set to be updated
---> Package php-xmlrpc.i386 0:5.2.17-1.el5 set to be updated
--> Finished Dependency Resolution
 
Dependencies Resolved
 
===========================================================================================================================================================
 Package                                 Arch                            Version                                  Repository                          Size
===========================================================================================================================================================
Updating:
 php                                     i386                            5.2.17-1.el5                             CentALT                            1.2 M
Installing for dependencies:
 libevent                                i386                            1.4.13-1                                 base                               112 k
Updating for dependencies:
 php-cli                                 i386                            5.2.17-1.el5                             CentALT                            2.3 M
 php-common                              i386                            5.2.17-1.el5                             CentALT                            275 k
 php-devel                               i386                            5.2.17-1.el5                             CentALT                            552 k
 php-gd                                  i386                            5.2.17-1.el5                             CentALT                            121 k
 php-imap                                i386                            5.2.17-1.el5                             CentALT                             51 k
 php-ldap                                i386                            5.2.17-1.el5                             CentALT                             33 k
 php-mbstring                            i386                            5.2.17-1.el5                             CentALT                            1.1 M
 php-mysql                               i386                            5.2.17-1.el5                             CentALT                             82 k
 php-ncurses                             i386                            5.2.17-1.el5                             CentALT                             38 k
 php-odbc                                i386                            5.2.17-1.el5                             CentALT                             50 k
 php-pdo                                 i386                            5.2.17-1.el5                             CentALT                             63 k
 php-pgsql                               i386                            5.2.17-1.el5                             CentALT                             67 k
 php-snmp                                i386                            5.2.17-1.el5                             CentALT                             26 k
 php-xml                                 i386                            5.2.17-1.el5                             CentALT                            112 k
 php-xmlrpc                              i386                            5.2.17-1.el5                             CentALT                             54 k
 
Transaction Summary
===========================================================================================================================================================
Install       1 Package(s)
Upgrade      16 Package(s)
 
Total download size: 6.2 M
Is this ok [y/N]: y
...
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
....
Updated:
  php.i386 0:5.2.17-1.el5                                                                                              ...
Complete!

Step 5. Verify PHP version and restart httpd service to apply it:

$ php --version
PHP 5.2.17 (cli) (built: Jan  7 2011 10:51:53) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
 
$ /etc/init.d/httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

Let me know if you face any issues or have query by putting a comment below.

More helpful articles you may like to read:
* Upgrade PHP to its latest version by compiling source.
* 5 steps to secure your Linux Server
* Ensuring secure access to prod Linux hosts

  • tjerk

    A better solution is to use PHP recommend Yum repo http://iuscommunity.org/
    Easy to install and you can decided in YUM wich stable version you want to install like:
    yum install php52
    yum install php53
    yum install php2-mysql

  • http://avz.org.ua sysadmin

    What is the latest release of PHP 5.2.x branch? Where can I get it?

  • http://linuxadminzone.com jagbir

    Hi sysadmin, PHP 5.2.x has been discontinued. 5.4.3 is latest stable which you can download from: http://php.net/downloads.php

  • http://avz.org.ua sysadmin

    Yes, I know that 5.2 is very obsolete, but some my badly-written sites require it. So, I need to support 5.2 branch too (by compiling php-cgi binary from source). Is it right, that the latest 5.2.x version is 5.2.17? Thank you for reply.

  • http://linuxadminzone.com jagbir

    Hi sysadmin, yes 5.2.17 is latest in 5.2 branch, I just scanned the releases: http://www.php.net/ChangeLog-5.php#5.2.0 and have this impression.

Previous post:

Next post: