设为首页 收藏本站
查看: 344|回复: 0

[经验分享] CentOS PHP 5.1 升级到 5.2

[复制链接]

尚未签到

发表于 2018-12-20 11:45:14 | 显示全部楼层 |阅读模式
  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:
  

  

  

  

  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

Extras

Updating/Installing mcrypt
  If you have php-mcrypt for PHP 5.1.x installed you'll want to remove it:

  Note: Your version number maybe different.>  

  
rpm -e php-mcrypt-5.1.6-15.el5.centos.1
  

  

  Download php-mcrypt for PHP 5.2.x and install it. You can find a 32-bit php-mcrypt package here FedoraJunkies.
  Note: You'll notice the "--nodeps" flag in the example. When you try to install php-mcrypt without it you get an error that php-common-5.2.6-2.el5s2 is missing even though it is installed.
  

  
wget -c http://sourcemirrors.org/scotth/centos/5/php/php-mcrypt-5.2.6-2.i386.rpm
  
rpm -i --nodeps php-mcrypt-5.2.6-2.i386.rpm
  

  

  Restart Apache and you should now see mcrypt information on your testing.php page.

JSON and PDO being loaded twice
  When you run the command "php -v" you might see the following errors:
  

  
# php -v
  

  
PHP Warning:  Module 'json' already loaded in Unknown on line 0
  
PHP Warning:  Module 'PDO' already loaded in Unknown on line 0
  
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
  

  

  This is caused by the following two lines in the /etc/php.ini file:
  

  
; Extension JSON
  
extension=json.so
  

  
; Extension PDO
  
extension=pdo.so
  

  

  Comment out these lines by adding a ";" in front of "extension=". These two modules are already loaded via these two files:
  

  
/etc/php.d/json.ini
  
/etc/php.d/pdo.ini
  

  

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



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-653566-1-1.html 上篇帖子: PHP-显示当前时间-date() 下篇帖子: php趣味100例
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表