Skip to content
Bots!
Bots!
  • About
    • Myself
    • আমার দোয়া
  • Bookmarks
    • Bookmarks
    • My OCI Bookmarks
    • Useful Proxmox Commands & Links
    • Learning Nano
    • Useful Sites
    • Useful Virtualbox Command
    • Useful MySQL Command
    • Useful Linux Command
    • BTT-CAS
  • Resources
    • Webinar on Cloud Adoption for Project Managers
  • Photos
  • Videos
  • Downloads
Bots!

How to upgrade PHP 5.2 Centos

Rumi, April 27, 2011September 5, 2017

Method-1

This guide describes how to upgrade the standard PHP 5.1.x packages in CentOS 5.x 32-bit to the current development versions 5.2.x. These instructions were created using CentOS 5.3 32-bit and with the following PHP packages installed:

# rpm -qa |grep php

 php-common-5.1.6-15.el5.i386
 php-cli-5.1.6-15.el5.i386
 php-5.1.6-15.el5.i386
 php-pdo-5.1.6-15.el5.i386
 php-bcmath-5.1.6-15.el5.i386
 php-ldap-5.1.6-15.el5.i386
 php-devel-5.1.6-15.el5.i386
 php-gd-5.1.6-15.el5.i386
 php-xml-5.1.6-15.el5.i386
 php-mbstring-5.1.6-15.el5.i386
 php-mysql-5.1.6-15.el5.i386
 php-dba-5.1.6-15.el5.i386

As long as you’re using the standard PHP packages on your CentOS server you won’t need to do anything extra. If you’re using extra PHP packages that aren’t part of the standard CentOS repositories (like php-mcrypt) you’ll have to remove them or find updated versions of them.

Add the development repositories

First thing we need to do is add the development repositories to yum. When we add the development repository we’re going to configure it so it only pulls PHP packages. To start we’ll need create a new yum repository configuration file (use your favorite editor):

 # /etc/yum.repos.d/CentOS-Testing.repo

Copy/paste the following into this file:

  # CentOS-Testing:
  # !!!! CAUTION !!!!
  # This repository is a proving grounds for packages on their way to CentOSPlus and CentOS Extras.
  # They may or may not replace core CentOS packages, and are not guaranteed to function properly.
  # These packages build and install, but are waiting for feedback from testers as to
  # functionality and stability. Packages in this repository will come and go during the
  # development period, so it should not be left enabled or used on production systems without due
  # consideration.
  [c5-testing]
  name=CentOS-5 Testing
  baseurl=http://dev.centos.org/centos/$releasever/testing/$basearch/
  enabled=1
  gpgcheck=1
  gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing
  includepkgs=php*

Make sure to remove any spaces at the start of each line, then save and close the file and you’re done.

Update PHP packages

Before updating your PHP packages you’ll want to get a list of what you currently have installed. To get a list of current PHP packages run the following:

 # rpm -qa |grep php

Now you can use yum to update the PHP packages on your system:

 # yum update

You should be shown a list of packages that are going to be updated. Compare it to the list of PHP packages on your system. Note any packages that are not in the list. You’ll need to remove these packages or find updates for them because they won’t work after you update to PHP 5.2.x. If that is acceptable type “y” to continue and let yum update the packages.

Once yum has completed restart Apache:

 # service httpd restart

To verify the update is working create a simple testing.php in your www directory with the following source code:

<?php
  phpinfo();
?>

and open it in a web browser. The new PHP version should be reflected at the top of the page.

Conclusion

You should now have PHP 5.2.6 running on CentOS 5.3 32-bit.

 # rpm -qa |grep php

  php-cli-5.2.6-2.el5s2
  php-mbstring-5.2.6-2.el5s2
  php-devel-5.2.6-2.el5s2
  php-pdo-5.2.6-2.el5s2
  php-gd-5.2.6-2.el5s2
  php-dba-5.2.6-2.el5s2
  php-common-5.2.6-2.el5s2
  php-bcmath-5.2.6-2.el5s2
  php-xml-5.2.6-2.el5s2
  php-pear-1.5.1-2.el5s2
  php-ldap-5.2.6-2.el5s2
  php-5.2.6-2.el5s2
  php-mysql-5.2.6-2.el5s2


 # php -v

  PHP 5.2.6 (cli) (built: Sep 15 2008 20:42:05)
  Copyright (c) 1997-2008 The PHP Group
  Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies

Note: If your “php -v” output returns errors about PDO or JSON click here

 Src: http://wiki.centos.org/HowTos/PHP_5.1_To_5.2

Method-2

Alternative way if the above fails

[user@server ~]$ yum list installed | grep php | cut -d' ' -f1
php.x86_64
php-cli.x86_64
php-common.x86_64
php-devel.x86_64
php-gd.x86_64
php-mbstring.x86_64
php-mysql.x86_64
php-mcrypt.x86_64
php-pdo.x86_64
php-pear.noarch
php-pgsql.x86_64
php-xml.x86_64
php-xmlrpc.x86_64
[user@server ~]$

Next I checked to make sure that those packages were available for php53:

[user@server ~]$ yum search php53 | cut -d' ' -f1 | grep php
php53.x86_64
php53-bcmath.x86_64
php53-cli.x86_64
php53-common.x86_64
php53-dba.x86_64
php53-devel.x86_64
php53-gd.x86_64
php53-imap.x86_64
php53-intl.x86_64
php53-ldap.x86_64
php53-mbstring.x86_64
php53-mysql.x86_64
php53-odbc.x86_64
php53-pdo.x86_64
php53-pgsql.x86_64
php53-process.x86_64
php53-pspell.x86_64
php53-snmp.x86_64
php53-soap.x86_64
php53-xml.x86_64
php53-xmlrpc.x86_64
[use@server ~]$

First, I shut down the Apache server as I didn’t want people going to broken pages as I did these updates:

[user@server ~]$ sudo service httpd stop
Stopping httpd: [ OK ]
[user@server ~]$
[user@server ~]$ sudo yum remove php php-cli php-common php-devel php-gd php-mbstring php-mysql php-mcrypt php-pdo php-pear php-pgsql php-xml php-xmlrpc
Loaded plugins: fastestmirror, priorities
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package php.x86_64 0:5.2.16-jason.1 set to be erased
...
Remove 13 Package(s)
Reinstall 0 Package(s)
Downgrade 0 Package(s)
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
...
Complete!

Finally, I installed the available replacement packages:

[user@server ~]$ sudo yum install php53 php53-cli php53-common php53-devel php53-gd php53-mbstring php53-mysql php53-pdo php53-pgsql php53-xml php53-xmlrpc
Loaded plugins: fastestmirror, priorities
Loading mirror speeds from cached hostfile
 * base: centos.mirror.lstn.net
 * epel: fedora-epel.mirror.lstn.net
 * extras: mirror.ubiquityservers.com
 * updates: mirror.steadfast.net
Setting up Install Process
...
Install 2 Package(s)
Upgrade 0 Package(s)
Total download size: 18.5 M
Is this ok [y/N]: y
Downloading Packages:
...
Complete!
[user@server ~]$

Method-3

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
Administrations Configurations (Linux)

Post navigation

Previous post
Next post

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Myself…

Hi, I am Hasan T. Emdad Rumi, an IT Project Manager & Consultant, Virtualization & Cloud Savvyfrom Dhaka, Bangladesh. I have prior experience in managing numerous local and international projects in the area of Telco VAS & NMC, National Data Center & PKI Naitonal Root and CA Infrastructure. Also engaged with several Offshore Software Development Team.

Worked with Orascom Telecom-Banglalink, Network Elites as VAS partner, BTRC, BTT (Turkey) , Mango Teleservices Limited and Access to Informaiton (A2I-UNDP)

Currently working at Oracle Corporation as Principal Technology Solution and Cloud Architect.

You can reach me [h.t.emdad at gmail.com] and I will be delighted to exchange my views.

Tags

Apache Bind Cacti CentOS CentOS 6 CentOS 7 Debain Debian Debian 10 Debian 11 Debian 12 DKIM Docker endian icinga iptables Jitsi LAMP Letsencrypt Linux Munin MySQL Nagios Nextcloud NFS nginx pfsense php Postfix powerdns Proxmox RDP squid SSH SSL Ubuntu Ubuntu 16 Ubuntu 18 Ubuntu 20 Varnish virtualbox vpn Webmin XCP-NG zimbra

Topics

Recent Posts

  • Install Jitsi on Ubuntu 22.04 / 22.10 April 30, 2025
  • Key Lessons in life April 26, 2025
  • Create Proxmox Backup Server (PBS) on Debian 12 April 19, 2025
  • Add Physical Drive in Proxmox VM Guest April 19, 2025
  • Mount a drive permanently with fstab in Linux April 16, 2025
  • Proxmox 1:1 NAT routing March 30, 2025
  • Installation steps of WSL – Windows Subsystem for Linux March 8, 2025
  • Enabling Nested Virtualization In Proxmox March 8, 2025
  • How to Modify/Change console/SSH login banner for Proxmox Virtual Environment (Proxmox VE / PVE) March 3, 2025
  • Install Proxmox Backup Server on Debian 12 February 12, 2025

Archives

Top Posts & Pages

  • Install Jitsi on Ubuntu 22.04 / 22.10
©2025 Bots! | WordPress Theme by SuperbThemes