解掉煩人的 bug 心情十分開心,應該找人乾杯一下 |
# rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
# yum install -y php56w php56w-opcache php56w-xml php56w-mcrypt php56w-gd php56w-devel php56w-mysql php56w-intl php56w-mbstring
理論上這樣的設定應該可行,但一直出現相依性的錯誤,於是想其他辦法:
[移除 PHP5.5]
請先備份一下 /etc/php.ini
#yum remove php-common
[調整 repos 設定 ]
# vim /etc/yum.repos.d/remi.repo
新增以下內容
[remi-php56]
name=Les RPM de remi de PHP 5.6 pour Enterprise Linux 6 – $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/6/php56/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/6/php56/mirror
# WARNING: If you enable this repository, you must also enable “remi”
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
[安裝 PHP5.6]
# yum install php php-gd php-mysql php-mcrypt php-intl php-mysql php-devel php-gd php-mbstring
[修改 /etc/php.ini ]
請注意 date.timezone 會被還原成空白值,必須填入正確內容,例如 “Asia/Taipei”
建議比對之前的備份內容,視情況修改為先前的設定值
如果 timezone 是空白值,會出現以下錯誤訊息
Warning: phpinfo(): It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone ‘UTC’ for now, but please set date.timezone to select your timezone.
[修改 CodeIgniter 2x 核心]
升級到了 PHP5.6 之後,CI 2X 要做點修改,以下是錯誤訊息:
A PHP Error was encountered
Severity: Notice
Message: Only variable references should be returned by reference
Filename: core/Common.php
Line Number: 257
沒錯,就是 system/core/Common.php
257 行原本的程式碼是
return $_config[0] =& $config;
修改為
$_config[0] =& $config; return $_config[0];
[遇見錯誤,原來是移除 PHP55 時,也順便移除了 Imagick~ ]
# php -v
PHP Warning: PHP Startup: imagick: Unable to initialize module
Module compiled with module API=20121212
PHP compiled with module API=20131226
These options need to match
in Unknown on line 0
PHP 5.6.27RC1 (cli) (built: Sep 29 2016 09:59:58)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
[嘗試了以下方式,但沒用]
# yum install php-pecl-imagick
《解決方式》
# yum install ImageMagick ImageMagick-devel php-pear
// yum install gcc // gcc 是必要的,如果沒裝一定要裝
// yum install gcc gcc-c++ autoconf automake // 如果還有錯誤,這是完整安裝
# pecl install imagick
# vim /etc/php.ini
在最後加上
extension=imagick.so
重啟 httpd 之後
# php -v
PHP Warning: Module ‘imagick’ already loaded in Unknown on line 0
PHP 5.6.27RC1 (cli) (built: Sep 29 2016 09:59:58)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
再修改
# vim /etc/php.ini
把剛剛加上的內容移除
extension=imagick.so
# php -v
PHP 5.6.27RC1 (cli) (built: Sep 29 2016 09:59:58)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
終於大功告成!沒有異常的通知。
註:網路上都建議要在 /etc/php.ini 上加入 extension=imagick.so ,但實際結果在本機上會出現 “already loaded in Unknown on line 0” 的錯誤訊息,因此才會再修改 /etc/php.ini ,並移除 extension=imagick.so
《參考資料》
How to Upgrade PHP version 5.4 to 5.6 on CentOS/RHEL 6/7(Photo via Gaby Av / Cheers, CC License)
沒有留言:
張貼留言