注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

isblog主页

或许不一定要做得最多,但一定要做得最好! 能力就是一种财富,积累越多,就越体现你

 
 
 

日志

 
 

CentOS 安装php5.2三种方法  

2012-04-22 17:44:10|  分类: linux |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

 一、源代码安装

下载源代码,目前看来还是最好的方法,虽然不像后两种傻瓜,但是确实灵活,方便的多。也不至于缺少为缺少某个模块被囧死。

./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/lib --with-apxs2=/usr/sbin/apxs --with-mysql --with-gd --with-mcrypt --enable-mbstring -enable-cli

[root@localhost php-5.2.14]# make install
Installing PHP SAPI module: apache2handler
/usr/lib/httpd/build/instdso.sh SH_LIBTOOL='/usr/lib/apr-1/build/libtool' libphp5.la /usr/lib/httpd/modules
/usr/lib/apr-1/build/libtool --mode=install cp libphp5.la /usr/lib/httpd/modules/
cp .libs/libphp5.so /usr/lib/httpd/modules/libphp5.so
cp .libs/libphp5.lai /usr/lib/httpd/modules/libphp5.la
libtool: install: warning: remember to run `libtool --finish /home/niyeqing/php-5.2.14/libs'
chmod 755 /usr/lib/httpd/modules/libphp5.so
[activating module `php5' in /etc/httpd/conf/httpd.conf]
Installing PHP CLI binary: /usr/local/php5/bin/
Installing PHP CLI man page: /usr/local/php5/man/man1/
Installing build environment: /usr/local/php5/lib/php/build/
Installing header files: /usr/local/php5/include/php/
Installing helper programs: /usr/local/php5/bin/
program: phpize
program: php-config
Installing man pages: /usr/local/php5/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /usr/local/php5/lib/php/
[PEAR] Archive_Tar - already installed: 1.3.7
[PEAR] Console_Getopt - already installed: 1.2.3
[PEAR] Structures_Graph- already installed: 1.0.3
[PEAR] XML_Util - already installed: 1.2.1
[PEAR] PEAR - already installed: 1.9.1
Wrote PEAR system config file at: /usr/local/php5/etc/pear.conf
You may want to add: /usr/local/php5/lib/php to your php.ini include_path
Installing PDO headers: /usr/local/php5/include/php/ext/pdo/

二、rpm安装

说实话,不建议。

几次折腾后也让我领教了rpm包严重的依赖问题,如果少了某一模块的时候,比较囧。

虽然有http://rpm.pbone.net/这样的网站

Oracle Enterprise Linux抢先一步提供了新版本PHP rpm安装包,包括php相关的扩展,同样适用于RHEL 4.7/5.3,提供x86 和x86_64两种版本。虽然官方宣称对这些软件包不提供技术支持,但是对于我们使用rpm安装升级提供了很多便利。

下载地址:http://oss.oracle.com/projects/php/files/

参考博客:http://www.wardking.com/blog/post/340/

三、yum安装

A方法:

先将以下地址导入。

# rpm --import http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

# vi /etc/yum.repos.d/CentOS-Base.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

执行命令,自动升级。

yum update php -y
yum install libmcrypt -y

参考博客:http://www.fallday.org/archives/434

B方法:CentOS源

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

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*

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


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. Alter below command accordingly.

 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://blog.163.com/nonnie@126/blog/static/5763030820103224710427/

  评论这张
 
阅读(1399)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017