facebook twitter hatena line email

「Linux/phpインストール/php7.0」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
 
(同じ利用者による、間の26版が非表示)
行3: 行3:
 
==remiリポジトリ追加==
 
==remiリポジトリ追加==
 
  cd /usr/local/src
 
  cd /usr/local/src
 +
 +
centos6の場合
 
  wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
 
  wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
 
  sudo rpm -Uvh remi-release-6*.rpm
 
  sudo rpm -Uvh remi-release-6*.rpm
 +
 +
centos7の場合
 +
wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
 +
rpm -Uvh remi-release-7.rpm
  
 
==apache,mysql,nginxのサービス停止&アンインストール==
 
==apache,mysql,nginxのサービス停止&アンインストール==
行37: 行43:
 
  --enablerepo=remi
 
  --enablerepo=remi
  
php7.0のphp-pecl-xhprofはエラーになった・・・
+
php7.0のphp-pecl-xhprofはエラーになった・・・これについては最下参照。
 
  sudo yum -y install php-pecl-xhprof.x86_64
 
  sudo yum -y install php-pecl-xhprof.x86_64
 
  エラー: パッケージ: php-pecl-xhprof-0.9.4-1.el6.x86_64 (epel)
 
  エラー: パッケージ: php-pecl-xhprof-0.9.4-1.el6.x86_64 (epel)
行54: 行60:
 
  sudo yum -y install php-pear --enablerepo=remi-php70
 
  sudo yum -y install php-pear --enablerepo=remi-php70
 
  $ php -v
 
  $ php -v
 +
 +
==php7.0でつまずくところ==
 +
===Smarty-2系でエラーになる===
 +
Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/zend/twi/library/Smarty-2.6.18/libs/Smarty_Compiler.class.php on line 271
 +
戻り値がnullになる様子。
 +
 +
参考:http://qiita.com/DQNEO/items/02a6c0234ed09dd4a5f3
 +
 +
最新のSmarty2だと直ってるっぽい。
 +
 +
修正前
 +
$source_content = preg_replace($search.'e', "'"
 +
                                      . $this->_quote_replace($this->left_delimiter) . 'php'
 +
                                      . "' . str_repeat(\"\n\", substr_count('\\0', \"\n\")) .'"
 +
                                      . $this->_quote_replace($this->right_delimiter)
 +
                                      . "'"
 +
 +
修正後
 +
$source_content = preg_replace_callback($search, create_function ('$matches', "return '"
 +
                                      . $this->_quote_replace($this->left_delimiter) . 'php'
 +
                                      . "' . str_repeat(\"\n\", substr_count('\$matches[1]', \"\n\")) .'"
 +
                                      . $this->_quote_replace($this->right_delimiter)
 +
                                      . "';")
 +
 +
smarty2公式差分:https://github.com/smarty-php/smarty/commit/0ecdd6c41d0de08cba846087abd02a9adb5218e5
 +
 +
===php7のphp_mecabエラー対応方法===
 +
[[mecab/php7実装]] [ショートカット]
 +
 +
===php7のxhprofエラー対応方法===
 +
[[php/速度改善/XHProf/php7]] [ショートカット]
 +
 +
===メソッドの引数の数と型を同じにしないとWarningが発生する===
 +
Warning: Declaration of %s::%s() should be compatible with that of %s::%s()
 +
 +
===smarty2-cache-memcacheとxhprofを導入時のphp7エラー対応===
 +
xhprof_enable();実行後、
 +
 +
smartyのrender箇所でテンプレートファイルのコンパイルファイルが作成されずに502エラーとなった。
 +
 +
xhprofを外しsmarty-cacheのid(memcache_id)を変更することで回避。
 +
 +
テンプレのコンパイルを作った後であればxhprofは使える・・・。
 +
 +
非公式のphp7-xhprofとsmarty2の組み合わせは悪いかもしれない。
 +
 +
===cactiのphp7対応===
 +
まだ対応してないっぽい(2016/3/3)
 +
 +
*その1
 +
以下サイトに"=&"を"="にすればと書いてあったので、やってみましたが真っ白になりました。
 +
mysql_pconnect()が引っかかるっぽい。
 +
 +
http://pcboy.dip.jp/xoopscube/modules/xpress/?p=677
 +
 +
*その2
 +
以下githubに上がっているphp7alpha対応のcactiを使ってみたけどmysql_queryが使えないと言われた。(lib/adodb/drivers/adodb-mysql.inc.php:468)
 +
 +
https://github.com/daniel-widrick/cacti-0.8.8d-to-php7alpha
 +
 +
==timezoneエラー==
 +
date.timezone = Asia/Tokyo ; /etc/php.ini

2017年9月3日 (日) 00:12時点における最新版

epelリポジトリ追加

sudo yum -y install epel-release

remiリポジトリ追加

cd /usr/local/src

centos6の場合

wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
sudo rpm -Uvh remi-release-6*.rpm

centos7の場合

wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm

apache,mysql,nginxのサービス停止&アンインストール

sudo /etc/rc.d/init.d/httpd stop
sudo /etc/rc.d/init.d/nginx stop
sudo /etc/rc.d/init.d/php-fpm stop
sudo /etc/rc.d/init.d/mysqld stop
sudo yum list installed | grep php-*
sudo yum list installed | grep mysql-*
sudo yum remove php-*
sudo yum remove mysql

php7.0インストール(64bit)

sudo yum -y install php.x86_64 --enablerepo=remi --enablerepo=remi-php70
sudo yum -y install php-mbstring.x86_64 --enablerepo=remi --enablerepo=remi-php70
sudo yum -y install php-mcrypt.x86_64 --enablerepo=remi --enablerepo=remi-php70
sudo yum -y install php-devel.x86_64 --enablerepo=remi --enablerepo=remi-php70
sudo yum -y install php-mysql.x86_64 --enablerepo=remi --enablerepo=remi-php70
sudo yum -y install php-pecl-memcached.x86_64 --enablerepo=remi --enablerepo=remi-php70
sudo yum -y install php-gd.x86_64 --enablerepo=remi --enablerepo=remi-php70
sudo yum -y install php-opcache.x86_64 --enablerepo=remi,remi-php70 
sudo yum -y install php-fpm.x86_64 --enablerepo=remi,remi-php70 
sudo yum -y install php-pecl-xhprof.x86_64
sudo yum -y install php-pear --enablerepo=remi-php70
$ php -v
PHP 7.0.2 (cli) (built: Jan  6 2016 15:33:31) ( 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

うまくいかない場合は以下remiを消してみる

--enablerepo=remi

php7.0のphp-pecl-xhprofはエラーになった・・・これについては最下参照。

sudo yum -y install php-pecl-xhprof.x86_64
エラー: パッケージ: php-pecl-xhprof-0.9.4-1.el6.x86_64 (epel)

php7.0インストール(32bit)

sudo yum -y install php.i686 --enablerepo=remi --enablerepo=remi-php70
sudo yum -y install php-mbstring.i686 --enablerepo=remi --enablerepo=remi-php70
sudo yum -y install php-mcrypt.i686 --enablerepo=remi --enablerepo=remi-php70
sudo yum -y install php-devel.i686 --enablerepo=remi --enablerepo=remi-php70
sudo yum -y install php-mysql.i686 --enablerepo=remi --enablerepo=remi-php70
sudo yum -y install php-pecl-memcached.i686 --enablerepo=remi --enablerepo=remi-php70
sudo yum -y install php-gd.i686 --enablerepo=remi --enablerepo=remi-php70
sudo yum -y install --enablerepo=remi,remi-php70 php-opcache.i686
sudo yum -y install php-fpm.i686 --enablerepo=remi,remi-php70 
sudo yum -y install php-pecl-xhprof.i686 --enablerepo=remi --enablerepo=remi-php70
sudo yum -y install php-pear --enablerepo=remi-php70
$ php -v

php7.0でつまずくところ

Smarty-2系でエラーになる

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/zend/twi/library/Smarty-2.6.18/libs/Smarty_Compiler.class.php on line 271

戻り値がnullになる様子。

参考:http://qiita.com/DQNEO/items/02a6c0234ed09dd4a5f3

最新のSmarty2だと直ってるっぽい。

修正前

$source_content = preg_replace($search.'e', "'"
                                      . $this->_quote_replace($this->left_delimiter) . 'php'
                                      . "' . str_repeat(\"\n\", substr_count('\\0', \"\n\")) .'"
                                      . $this->_quote_replace($this->right_delimiter)
                                      . "'"

修正後

$source_content = preg_replace_callback($search, create_function ('$matches', "return '"
                                      . $this->_quote_replace($this->left_delimiter) . 'php'
                                      . "' . str_repeat(\"\n\", substr_count('\$matches[1]', \"\n\")) .'"
                                      . $this->_quote_replace($this->right_delimiter)
                                      . "';")

smarty2公式差分:https://github.com/smarty-php/smarty/commit/0ecdd6c41d0de08cba846087abd02a9adb5218e5

php7のphp_mecabエラー対応方法

mecab/php7実装 [ショートカット]

php7のxhprofエラー対応方法

php/速度改善/XHProf/php7 [ショートカット]

メソッドの引数の数と型を同じにしないとWarningが発生する

Warning: Declaration of %s::%s() should be compatible with that of %s::%s()

smarty2-cache-memcacheとxhprofを導入時のphp7エラー対応

xhprof_enable();実行後、

smartyのrender箇所でテンプレートファイルのコンパイルファイルが作成されずに502エラーとなった。

xhprofを外しsmarty-cacheのid(memcache_id)を変更することで回避。

テンプレのコンパイルを作った後であればxhprofは使える・・・。

非公式のphp7-xhprofとsmarty2の組み合わせは悪いかもしれない。

cactiのphp7対応

まだ対応してないっぽい(2016/3/3)

  • その1

以下サイトに"=&"を"="にすればと書いてあったので、やってみましたが真っ白になりました。 mysql_pconnect()が引っかかるっぽい。

http://pcboy.dip.jp/xoopscube/modules/xpress/?p=677

  • その2

以下githubに上がっているphp7alpha対応のcactiを使ってみたけどmysql_queryが使えないと言われた。(lib/adodb/drivers/adodb-mysql.inc.php:468)

https://github.com/daniel-widrick/cacti-0.8.8d-to-php7alpha

timezoneエラー

date.timezone = Asia/Tokyo ; /etc/php.ini