How to upgrade PHP5.1 to 5.2.17 using YUM in CentOS

Source: Internet
Author: User
Tags gpg install php centos zend


There are many similar online tutorials, but many of them have expired or are useless. I used the following method last night. It's good, simple, and easy to use.
 
 

The code is as follows: Copy code
# Cat/etc/issue

System version: CentOS release 5.9 (Final)
 
1. Add yum source

The code is as follows: Copy code

# Cd/etc/yum. repos. d/
# Vim test. repo

Paste the following content:

The code is as follows: Copy code

[Utterramblings]
Name = Jason's Utter Ramblings Repo
Baseurl = http://www.jasonlitka.com/media/el?releasever/?basearch/
Enabled = 1
Gpgcheck = 1
Gpgkey = http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

Save and exit!

2. yum update php
 

The code is as follows: Copy code
Php-v
PHP 5.3.27 (cli) (built: Jul 13 2013 22:31:41)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies

You can also refer to this (not translated in English)


Install the extra repositories
The first step requires downloading and installing some RPM files that contain the additional repository definitions, which we'll do with the rpm command:

The code is as follows: Copy code
Sudo rpm-Uvh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
Sudo rpm-Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm

Once installed you shocould see some additional repository definitions under the/etc/yum. repos. d directory.

The code is as follows: Copy code
$ Ls-1/etc/yum. repos. d/epel */etc/yum. repos. d/webtatic. repo
/Etc/yum. repos. d/epel. repo
/Etc/yum. repos. d/epel-testing.repo
/Etc/yum. repos. d/webtatic. repo

Enable the webtatic repository
The webtatic repository provides a variety of up-to-date packages that are useful or are a requirement for your popular web-based services. that means it generally is not a bad idea to enable the webtatic repository by default.

First, open the/etc/yum. repos. d/webtatic. repo repository file using a text editor of your choice,

The code is as follows: Copy code
Sudo vim/etc/yum. repos. d/webtatic. repo

Edit the [webtatic] section of the file so that the enabled option is set to 1. This will enable the remi repository.

The code is as follows: Copy code
[Webtatic]
Name = Webtatic Repository $ releasever-$ basearch
# Baseurl = http://repo.webtatic.com/yum/centos/5/?basearch/
Export List = http://repo.webtatic.com/yum/centos/5/?basearch/#list
Enabled = 1
Gpgcheck = 1
Gpgkey = file: // etc/pki/rpm-gpg/RPM-GPG-KEY-webtatic-andy

Installing the PHP 5.3 packages
This section will aim to install PHP 5.3 and any relevant additional modules that may be required. If you are upgrading from an older PHP version to PHP 5.3 please skip to the next section.

The following is an example of a single-shot command of the installation of PHP 5.3 and some common modules:

$ Sudo yum install php-cli php-gd php-mysql php-mbstringThe following is a sample trace output (make note of the package version and the repository ):

...
Dependencies Resolved

========================================================== ==========================================================
Package Arch Version Repository Size
========================================================== ==========================================================
Installing:
Php x86_64 5.3.20-1. w5 webtatic 1.4 M
Php-cli x86_64 5.3.20-1. w5 webtatic 2.6 M
Php-gd x86_64 5.3.20-1. w5 webtatic 108 k
Php-mbstring x86_64 5.3.20-1. w5 webtatic 1.2 M
Php-mysql x86_64 5.3.20-1. w5 webtatic 91 k
Installing for dependencies:
Apr x86_64 1.3.12-1. w5 webtatic 102 k
Apr-util x86_64 1.3.12-1. w5 webtatic 84 k
Apr-util-ldap x86_64 1.3.12-1. w5 webtatic 15 k
...
Transaction Summary
========================================================== ==========================================================
Install 26 Package (s)
Upgrade 0 Package (s)
...
Warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID cf4c4ff9
Webtatic/gpgkey | 1.6 kB: 00
Importing GPG key 0xCF4C4FF9 "Andy Thompson <xx@xx.com>" from/etc/pki/rpm-gpg/RPM-GPG-KEY-webtatic-andy
Is this OK [y/N]: y
...
To search for available PHP-related packages we can run the following command:

Yum search php
Typically the names of php modules begin with php-. Be careful about any packages that start with php53-as these will conflict with the webtatic versions.

Once you 've installed PHP and any required supporting modules, skip to the "Last Steps" section below.

Upgrading to PHP 5.3 packages
If you already have PHP installed the upgrade steps are slightly different.

Warning: Before grouping Ming this upgrade please take the time to do a full backup of your system. The upgrade shocould generally be straightforward, but this will depend on the existing package state of your system.

To upgrade php, run:

$ Rpm-q php
Php-5.1.6-27.el5_5.3
$ Sudo yum upgrade php
...
Dependencies Resolved

========================================================== ========================================================== ===
Package Arch Version Repository
Size
========================================================== ========================================================== ===
Updating:
Php x86_64 5.3.20-1. w5 webtatic 1.4 M
Installing for dependencies:
...

Updating for dependencies:
Php-cli x86_64 5.3.20-1. w5 webtatic 2.6 M
Php-gd x86_64 5.3.20-1. w5 webtatic 108 k
Php-mbstring x86_64 5.3.20-1. w5 webtatic 1.2 M
Php-mysql x86_64 5.3.20-1. w5 webtatic 91 k

Transaction Summary
========================================================== ========================================================== ===
...

$ Rpm-q php
Php-5.3.20-1.w5
The above commands will check the installed PHP version then update the existing php package and any associated packages to the 5.3 version in the webtatic and epel repositories.

Last steps
At this point you shoshould have PHP 5.3 installed using the webtatic package repository. The last thing to do is to restart apache if it is currently running so that the new PHP version is loaded.

$ Sudo/etc/init. d/httpd restart
A quick confirmation from the terminal shocould let you check the PHP version:

$ Php-v
PHP 5.3.20 (cli) (built: Dec 20 2012 18:11:02)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.