[Centos6] php5.3升級為php5.6

URL Link //n.sfs.tw/12503

2018-07-12 01:22:15 By 張○○

無奈的情況下升級 php5.3 為 php5.6。

無奈的原因是因為某來路不明的程設師說我的php5.3太舊跑不動他的程式碼,非常豪小,算了,我就升給你跑行不行。主要參考[1]的步驟。

原系統

CentOS release 6.10 (Final) 2011年建置

PHP 5.3.3 (cli) (built: Mar 22 2017 12:27:09)

 

安裝 Remi、Epel

# wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm && rpm -Uvh epel-release-latest-6.noarch.rpm

 

修改 yum 儲存池

vi  /etc/yum.repos.d/remi.repo

把下面enabled(粉紅色)的部分設成1


[remi]
name=Remi's RPM repository for Enterprise Linux 6 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/6/remi/$basearch/
#mirrorlist=https://rpms.remirepo.net/enterprise/6/remi/httpsmirror
mirrorlist=http://cdn.remirepo.net/enterprise/6/remi/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

 

[remi-php56]
name=Remi's PHP 5.6 RPM repository for Enterprise Linux 6 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/6/php56/$basearch/
#mirrorlist=https://rpms.remirepo.net/enterprise/6/php56/httpsmirror
mirrorlist=http://cdn.remirepo.net/enterprise/6/php56/mirror
# NOTICE: common dependencies are in "remi-safe"
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

 

升級PHP

# yum upgrade php*

如果你一切順利,恭禧你重啟後就完成法。

但是我遇到下面的錯誤:

Error Downloading Packages:
  php-fedora-autoloader-1.0.0-1.el6.noarch: failure: Packages/p/php-fedora-autoloader-1.0.0-1.el6.noarch.rpm from epel: [Errno 256] No more mirrors to try.
  libwebp-0.4.3-3.el6.x86_64: failure: Packages/l/libwebp-0.4.3-3.el6.x86_64.rpm from epel: [Errno 256] No more mirrors to try.

有兩個 packages 找不到來源,只好手動下載。

到yum暫停rpm的地方

# cd /var/cache/yum/x86_64/6/remi/packages/

下載yum無法自動找到的 packages

安裝

# rpm -Uvh php-fedora-autoloader-1.0.0-1.el6.noarch.rpm
# rpm -Uvh libwebp-0.4.3-3.el6.x86_64.rpm

重新執行 php升級

# yum upgrade php*

重啟 apache

# apachectl restart

升級完成

# php -v

PHP 5.6.36 (cli) (built: Apr 25 2018 10:11:47)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

 

參考資料

[1] https://www.zerostopbits.com/how-to-upgrade-php-5-3-to-php-5-6-on-centos-6-7/