php 7.0

回覆文章
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

php 7.0

文章 yehlu »

https://webtatic.com/packages/php70/

代碼: 選擇全部

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install php70w-fpm php70w-opcache
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Re: php 7.0

文章 yehlu »

代碼: 選擇全部

yum remove php-common-5.6.32
php-common x86_64 5.6.32-1.el7.remi @remi-php56 7.8 M
Removing for dependencies:
php x86_64 5.6.32-1.el7.remi @remi-php56 8.6 M
php-cli x86_64 5.6.32-1.el7.remi @remi-php56 13 M
php-fpm x86_64 5.6.32-1.el7.remi @remi-php56 4.3 M
php-gd x86_64 5.6.32-1.el7.remi @remi-php56 240 k
php-mbstring x86_64 5.6.32-1.el7.remi @remi-php56 2.7 M
php-mcrypt x86_64 5.6.32-1.el7.remi @remi-php56 97 k
php-mysqlnd x86_64 5.6.32-1.el7.remi @remi-php56 1.0 M
php-pdo x86_64 5.6.32-1.el7.remi @remi-php56 397 k
php-pecl-jsonc x86_64 1.3.10-2.el7.remi.5.6 @remi-php56 189 k
php-pecl-zip x86_64 1.15.2-1.el7.remi.5.6 @remi-php56 180 k
php-xml x86_64 5.6.32-1.el7.remi @remi-php56 882 k
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Re: php 7.0

文章 yehlu »

http://xyz.cinc.biz/2015/12/centos7-install-php7.html

結論:PHP 升級到 PHP7 後,速度有很明顯的提升。
但要注意跟舊程式不相容的地方。
PHP7: Backward incompatible changes - Manual
PHP7: Changed functions - Manual
PHP7: Removed Extensions and SAPIs - Manual
PHP7: Other Changes - Manual


環境:CentOS 7,原本已安裝 remi 的 PHP 5.4.37,要升級為PHP 7
$ php -v
PHP 5.4.37 (cli) (built: Jan 21 2015 11:35:44)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
安裝含 PHP7 的 remi repo
$ rpm -Uvh http://download.fedoraproject.org/pub/e ... noarch.rpm
$ rpm -Uvh http://rpms.famillecollet.com/enterpris ... ease-7.rpm
查所有repo,可發現已經有相關的 repo
$ yum repolist all
repo id repo name status
.....
!remi Remi's RPM repository for Enterprise Linux 7 - x86_64 disabled
.....
remi-php70 Remi's PHP 7.0 RPM repository for Enterprise Linux 7 - x86_64 disabled
.....
後面會用到 yum-config-manager,若無此指令,可先用 yum search 查詢在那個套件再安裝
$ yum search yum-config-manager
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.yzu.edu.tw
* epel: mirror01.idc.hinet.net
* extras: ftp.yzu.edu.tw
* remi-safe: mirror.innosol.asia
* updates: ftp.yzu.edu.tw
=================================== Matched: yum-config-manager ===================================
remi-release.noarch : YUM configuration for remi repository
yum-utils.noarch : Utilities based around the yum package manager
$ yum install yum-utils
開啟 remi、remi-php70
$ yum-config-manager --enable remi
$ yum-config-manager --enable remi-php70
升級所有相關的php套件 (若是初次安裝,可只執行 yum install php,再依需要安裝其他套件)
$ yum update php*
某些套件還沒有對應的新版本,會失敗,由錯誤訊息找出那些套件。
Error: Package: php-pecl-memcache-3.0.8-4.el7.remi.5.4.x86_64 (@remi)
Error: Package: php-pecl-igbinary-1.2.1-1.el7.remi.5.4.x86_64 (@remi)
先移除沒新版本的套件
$ yum remove php-pecl-igbinary
$ yum remove php-pecl-memcache 我安裝時 igbinary 還沒有PHP7的版本,(最新版本可查看 https://github.com/igbinary/igbinary/)
移除 php-pecl-igbinary 時,相依的 php-pecl-memcached 也移除了,等升級後再安裝新的。
php-pecl-memcache 我沒用到,之後就不裝了。

移除後再執行升級
$ yum update php*
================================================================================================
Package Arch Version Repository Size
================================================================================================
Installing:
php-mysqlnd x86_64 7.0.0-1.el7.remi remi-php70 228 k
replacing php-mysql.x86_64 5.4.37-1.el7.remi
Updating:
php x86_64 7.0.0-1.el7.remi remi-php70 2.6 M
php-bcmath x86_64 7.0.0-1.el7.remi remi-php70 58 k
php-cli x86_64 7.0.0-1.el7.remi remi-php70 3.9 M
php-common x86_64 7.0.0-1.el7.remi remi-php70 1.1 M
php-fpm x86_64 7.0.0-1.el7.remi remi-php70 1.3 M
php-gd x86_64 7.0.0-1.el7.remi remi-php70 64 k
php-mbstring x86_64 7.0.0-1.el7.remi remi-php70 562 k
php-pdo x86_64 7.0.0-1.el7.remi remi-php70 113 k
php-pear noarch 1:1.10.1-1.el7.remi remi 349 k
php-pecl-msgpack x86_64 2.0.0-1.el7.remi.7.0 remi-php70 53 k
php-process x86_64 7.0.0-1.el7.remi remi-php70 69 k
php-xml x86_64 7.0.0-1.el7.remi remi-php70 198 k
Installing for dependencies:
gd-last x86_64 2.1.1-2.el7.remi remi 140 k
php-json x86_64 7.0.0-1.el7.remi remi-php70 51 k

Transaction Summary
================================================================================================
Install 1 Package (+2 Dependent packages)
Upgrade 12 Packages

Total download size: 11 M
Is this ok [y/d/N]:

[安裝 php-pecl-memcached]
$ yum install php-pecl-memcached php-pecl-memcached 原本用 igbinary 當預設的 serializer,沒 igbinary 時,則改用 msgpack 當 serializer,
若有多台 server 分享存取的資料,要注意 serializer 是否相同。
(The default is igbinary if available, then msgpack if available, then php otherwise.)
$ php -i | grep memcached.serializer
memcached.serializer => msgpack => msgpack
[安裝 pecl-zip]
$ yum install php-pecl-zip
[性能相關]
安裝 OPcache、開啟 HugePage、Opcache file cache
$ yum install php-opcache
編輯 OPcache 設定檔
$ vi /etc/php.d/10-opcache.ini
zend_extension=opcache.so
opcache.enable=1
opcache.enable_cli=1
opcache.huge_code_pages=1
opcache.file_cache=/home/opcache
建立 Opcache file cache 資料夾
$ mkdir /home/opcache
$ chown nginx.nginx /home/opcache
開啟 HugePage
查看作業系統目前設定
$ cat /proc/meminfo | grep Huge
AnonHugePages: 237568 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
修改 /etc/sysctl.conf 加上 vm.nr_hugepages 設定
$ vi /etc/sysctl.conf
vm.nr_hugepages=512
讓設定不用重開機立即生效:
$ sysctl -p
$ cat /proc/meminfo | grep Huge
AnonHugePages: 237568 kB
HugePages_Total: 512
HugePages_Free: 512
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
重啟 PHP FPM
$ systemctl restart php-fpm.service
$ cat /proc/meminfo | grep Huge
AnonHugePages: 237568 kB
HugePages_Total: 512
HugePages_Free: 302
HugePages_Rsvd: 55
HugePages_Surp: 0
Hugepagesize: 2048 kB
$ php -v
PHP 7.0.0 (cli) (built: Dec 1 2015 17:53:27) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
更新完,新裝的套件如下
$ yum list installed | grep php
php.x86_64 7.0.0-1.el7.remi @remi-php70
php-bcmath.x86_64 7.0.0-1.el7.remi @remi-php70
php-cli.x86_64 7.0.0-1.el7.remi @remi-php70
php-common.x86_64 7.0.0-1.el7.remi @remi-php70
php-fpm.x86_64 7.0.0-1.el7.remi @remi-php70
php-gd.x86_64 7.0.0-1.el7.remi @remi-php70
php-json.x86_64 7.0.0-1.el7.remi @remi-php70
php-mbstring.x86_64 7.0.0-1.el7.remi @remi-php70
php-mysqlnd.x86_64 7.0.0-1.el7.remi @remi-php70
php-opcache.x86_64 7.0.0-1.el7.remi @remi-php70
php-pdo.x86_64 7.0.0-1.el7.remi @remi-php70
php-pear.noarch 1:1.10.1-1.el7.remi @remi
php-pecl-memcached.x86_64 2.2.0-11.20150628git3c79a97.el7.remi.7.0
@remi-php70
php-pecl-msgpack.x86_64 2.0.0-1.el7.remi.7.0 @remi-php70
php-pecl-zip.x86_64 1.13.1-3.el7.remi.7.0 @remi-php70
php-process.x86_64 7.0.0-1.el7.remi @remi-php70
php-xml.x86_64 7.0.0-1.el7.remi @remi-php70
原本舊的套件
$ yum list installed | grep php
php.x86_64 5.4.37-1.el7.remi @remi
php-bcmath.x86_64 5.4.37-1.el7.remi @remi
php-cli.x86_64 5.4.37-1.el7.remi @remi
php-common.x86_64 5.4.37-1.el7.remi @remi
php-fpm.x86_64 5.4.37-1.el7.remi @remi
php-gd.x86_64 5.4.37-1.el7.remi @remi
php-mbstring.x86_64 5.4.37-1.el7.remi @remi
php-mysql.x86_64 5.4.37-1.el7.remi @remi
php-pdo.x86_64 5.4.37-1.el7.remi @remi
php-pear.noarch 1:1.9.5-3.el7.remi @remi
php-pecl-igbinary.x86_64 1.2.1-1.el7.remi.5.4 @remi
php-pecl-memcache.x86_64 3.0.8-4.el7.remi.5.4 @remi
php-pecl-memcached.x86_64 2.2.0-3.el7.remi.5.4 @remi
php-pecl-msgpack.x86_64 0.5.5-7.el7.remi.5.4 @remi
php-process.x86_64 5.4.37-1.el7.remi @remi
php-xml.x86_64 5.4.37-1.el7.remi @remi

其他:
若要兩個版本併行可以使用 "php70-套件名"(例 php70-php-gd)的方式安裝,安裝完執行檔為php70,且 service 會多一個 php70-php-fpm,相關設定檔則放在 vi /etc/opt/remi/php70/ 底下 (但我裝完一直找不到 pdo-mysql)
$ php70 -v
PHP 7.0.0 (cli) (built: Dec 1 2015 16:06:41) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies

參考:
让PHP7达到最高性能的几个Tips | 风雪之隅
HugePage简介和KVM中使用HugePage - 咚咚锵锵 - 博客园
PHP version 7.0.0 is released! - Remi's RPM repository - Blog
php - Install PHP7 from Remi repo - Server Fault
14.7. Configuring Huge Pages in Red Hat Enterprise Linux 4 or 5
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Re: php 7.0

文章 yehlu »

php-cli.x86_64 7.0.27-1.el7.remi @remi-php70
php-common.x86_64 7.0.27-1.el7.remi @remi-php70
php-fpm.x86_64 7.0.27-1.el7.remi @remi-php70
php-gd.x86_64 7.0.27-1.el7.remi @remi-php70
php-json.x86_64 7.0.27-1.el7.remi @remi-php70
php-mbstring.x86_64 7.0.27-1.el7.remi @remi-php70
php-mcrypt.x86_64 7.0.27-1.el7.remi @remi-php70
php-mysqlnd.x86_64 7.0.27-1.el7.remi @remi-php70
php-pdo.x86_64 7.0.27-1.el7.remi @remi-php70
php-pecl-zip.x86_64 1.15.2-1.el7.remi.7.0 @remi-php70
php-xml.x86_64
回覆文章

回到「CentOS」