CentOS下YUM升级PHP5.1到5.2.17教程
2015-11-09 17:46
471 查看
网上类似的教程比较多,但是很多已经失效,或者没用。昨天晚上用了以下这个方法,还可以,简单 又好用。
系统版本: CentOS release 5.9 (Final)
1. 增加yum源
贴上如下内容:
保存退出!
2. yum update php
也可以参考一下这个(不会英文没有译)
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:
Once installed you should see some additional repository definitions under the /etc/yum.repos.d directory.
Enable the webtatic repository
The webtatic repository provides a variety of up-to-date packages that are useful or are a requirement for many 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,
Edit the [webtatic] section of the file so that the enabled option is set to 1. This will enable the remi repository.
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 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: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 performing this upgrade please take the time to do a full backup of your system. The upgrade should 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 should 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 should 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
代码如下 | 复制代码 |
#cat /etc/issue |
1. 增加yum源
代码如下 | 复制代码 |
#cd /etc/yum.repos.d/ #vim test.repo |
代码如下 | 复制代码 |
[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 |
2. yum update php
代码如下 | 复制代码 |
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 |
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:
代码如下 | 复制代码 |
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 |
代码如下 | 复制代码 |
$ 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 |
The webtatic repository provides a variety of up-to-date packages that are useful or are a requirement for many 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,
代码如下 | 复制代码 |
sudo vim /etc/yum.repos.d/webtatic.repo |
代码如下 | 复制代码 |
[webtatic] name=Webtatic Repository $releasever - $basearch #baseurl=http://repo.webtatic.com/yum/centos/5/$basearch/ mirrorlist=http://repo.webtatic.com/yum/centos/5/$basearch/mirrorlist enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-webtatic-andy |
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 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: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 performing this upgrade please take the time to do a full backup of your system. The upgrade should 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 should 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 should 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
相关文章推荐
- linux下vi编辑器常用命令
- centos crontab 定时执行任务使用大全
- linux笔记 第七天 文件查找find命令、文件特殊权限、while和until循环
- Centos6.5 rpm方式指定目录安装JDK
- linux学习资料
- linux搭建git远程版本库
- Linux NFS服务器的安装与配置方法(图文详解)
- 使用Linux命令行测试网速-----speedtest-cli
- 批量建立linux机器之间的ssh互信的自动化脚本
- Linux(suse11) 安装 JDK (.gz版本)
- CentOS yum安装mcrypt详细图解教程
- mysql文件目录详解 LINUX
- linux特殊字符
- linux命令:ls
- linux eclipse中C++连接mysql数据库
- Linux常用命令
- [转载]iTOP-4412开发板搭建最小linux系统
- 查看LinuxCPU个数
- Linux MTD系统剖析
- linux select 与 阻塞( blocking ) 及非阻塞 (non blocking)实现io多路复用的示例