CentOS 5.5 升級至 PHP 5.3

    版本為 15:03, 20 Nov 2024

    到這個版本。

    返回到 版本存檔.

    查閱目前版本

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

    系統環境:

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

    步驟開始: 方法一

    編譯 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

    方法二

    Powered by MindTouch Core