CentOS 5.5 升級至 PHP 5.3

    說明:在 CentOS 5 環境以 SOURCE RPM 方式升級 PHP。

    系統環境:

    • CentOS 5.5 32bit
    • PHP 5.1.6 (預設安裝)

    方法一:編譯 SRPM

    編譯 PHP 5.3 的 SOURCE RPM

    // 下載 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 安裝檔。

    安裝 PHP53 的所有套件

    // 關閉 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
    

     

    安裝完成。  

    F.A.Q

    雖然已安裝 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

    phpinfo_for_PHP53.png

    方法二:使用 yum 安裝

    系統環境: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
    
    標籤 (Edit tags)
    • No tags

    文件 1

    文件大小日期附件上傳者 
     phpinfo_for_PHP53.png
    phpinfo() for PHP 5.3
    936.39 KB14:40, 17 Feb 2011alang動作
    您必須 登入 才能發佈評論。
    Powered by MindTouch Core