說明:在 CentOS 5 環境以 SOURCE RPM 方式升級 PHP。
系統環境:
// 下載 source rpm
http://oss.oracle.com/projects/php/d...-1.el5.src.rpm
// 安裝需要的相依性套件
yum install bzip2-devel curl-devel db4-devel expat-devel gmp-devel aspell-devel httpd-devel libjpeg-devel libpng-devel pam-devel openssl-devel sqlite-devel libtool krb5-devel libc-client-devel cyrus-sasl-devel openldap-devel mysql-devel postgresql-devel unixODBC-devel net-snmp-devel libxslt-devel gd-devel freetype-devel
// 開始編譯
cd /usr/src/redhat/SRPMS rpmbuild --rebuild php53-5.3.5-1.el5.src.rpm
使用筆者的爛機器- Intel Celeron 1GHz 來作,大約花了一個小時的編譯時間。編譯完成後,會產生相關的 rpm 安裝檔,如下:
# ls /usr/src/redhat/RPMS/i386/php53* /usr/src/redhat/RPMS/i386/php53-5.3.5-1.i386.rpm /usr/src/redhat/RPMS/i386/php53-bcmath-5.3.5-1.i386.rpm /usr/src/redhat/RPMS/i386/php53-cli-5.3.5-1.i386.rpm /usr/src/redhat/RPMS/i386/php53-common-5.3.5-1.i386.rpm /usr/src/redhat/RPMS/i386/php53-dba-5.3.5-1.i386.rpm /usr/src/redhat/RPMS/i386/php53-devel-5.3.5-1.i386.rpm /usr/src/redhat/RPMS/i386/php53-gd-5.3.5-1.i386.rpm /usr/src/redhat/RPMS/i386/php53-imap-5.3.5-1.i386.rpm /usr/src/redhat/RPMS/i386/php53-ldap-5.3.5-1.i386.rpm /usr/src/redhat/RPMS/i386/php53-mbstring-5.3.5-1.i386.rpm /usr/src/redhat/RPMS/i386/php53-mysql-5.3.5-1.i386.rpm /usr/src/redhat/RPMS/i386/php53-odbc-5.3.5-1.i386.rpm /usr/src/redhat/RPMS/i386/php53-pdo-5.3.5-1.i386.rpm /usr/src/redhat/RPMS/i386/php53-pgsql-5.3.5-1.i386.rpm /usr/src/redhat/RPMS/i386/php53-snmp-5.3.5-1.i386.rpm /usr/src/redhat/RPMS/i386/php53-soap-5.3.5-1.i386.rpm /usr/src/redhat/RPMS/i386/php53-xml-5.3.5-1.i386.rpm /usr/src/redhat/RPMS/i386/php53-xmlrpc-5.3.5-1.i386.rpm
Tips:
如果Linux OS是 64 位元,Oracle 網站已經提供了所有的 RPM 安裝檔。
// 關閉 httpd 服務及移除舊版的 php 套件
# service httpd stop # service mysqld stop # rpm -qa | grep php php-cli-5.1.6-27.el5_5.3 php-5.1.6-27.el5_5.3 php-pdo-5.1.6-27.el5_5.3 php-mysql-5.1.6-27.el5_5.3 php-imap-5.1.6-27.el5_5.3 php-common-5.1.6-27.el5_5.3 php-gd-5.1.6-27.el5_5.3 php-ldap-5.1.6-27.el5_5.3 # cd /usr/src/redhat/RPMS/i386/ # rpm -ivh php53*.rpm # service mysqld start # service httpd start
安裝完成。
雖然已安裝 autoconf 2.59-12,但編譯時仍出現錯誤:You need autoconf version 2.13 or newer installed?
Ans: 這在編譯 PHP 時算是常見的錯誤,請安裝 autoconf213 套件,如下指令:
# yum install autoconf213 Then before you build set the environment variable to tell the build process which autoconf to use # export PHP_AUTOCONF="/usr/bin/autoconf-2.13"
phpinfo() for PHP 5.3
系統環境:CentOS 5.8
使用 remi 套件庫做線上升級
PHP 5.3.x)
wget http://mirror01.idc.hinet.net/EPEL/5/i386/epel-release-5-4.noarch.rpm wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm yum --enablerepo=remi update php
或者
使用 Utter Rambling 套件庫升級
PHP 5.2.x)
新增 /etc/yum.repos.d/utterramblings.repo
[utterramblings] name=Jason's Utter Ramblings Repo baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/ enabled=0 gpgcheck=1 gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
yum 安裝
yum --enablerepo=utterramblings update php
文件 | 大小 | 日期 | 附件上傳者 | |||
---|---|---|---|---|---|---|
phpinfo_for_PHP53.png phpinfo() for PHP 5.3 | 936.39 KB | 14:40, 17 Feb 2011 | alang | 動作 |
Images 1 | ||
---|---|---|
phpinfo() for PHP 5.3phpinfo_for_PHP53.png |