facebook twitter hatena line email

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

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(php8.0インストール(64bit))
行66: 行66:
 
smarty2公式差分:https://github.com/smarty-php/smarty/commit/0ecdd6c41d0de08cba846087abd02a9adb5218e5
 
smarty2公式差分:https://github.com/smarty-php/smarty/commit/0ecdd6c41d0de08cba846087abd02a9adb5218e5
  
===php7のphp_mecabエラー対応方法===
+
===php8のphp_mecabエラー対応方法===
 
[[mecab/php7実装]] [ショートカット]
 
[[mecab/php7実装]] [ショートカット]
  
===php7のxhprofエラー対応方法===
+
===php8のxhprofエラー対応方法===
 
[[php/速度改善/XHProf/php7]] [ショートカット]
 
[[php/速度改善/XHProf/php7]] [ショートカット]
  
行75: 行75:
 
  Warning: Declaration of %s::%s() should be compatible with that of %s::%s()
 
  Warning: Declaration of %s::%s() should be compatible with that of %s::%s()
  
===smarty2-cache-memcacheとxhprofを導入時のphp7エラー対応===
+
===smarty2-cache-memcacheとxhprofを導入時のphp8エラー対応===
 
xhprof_enable();実行後、
 
xhprof_enable();実行後、
  
行84: 行84:
 
テンプレのコンパイルを作った後であればxhprofは使える・・・。
 
テンプレのコンパイルを作った後であればxhprofは使える・・・。
  
非公式のphp7-xhprofとsmarty2の組み合わせは悪いかもしれない。
+
非公式のphp8-xhprofとsmarty2の組み合わせは悪いかもしれない。
  
===cactiのphp7対応===
+
===cactiのphp8対応===
 
まだ対応してないっぽい(2016/3/3)
 
まだ対応してないっぽい(2016/3/3)
  
行94: 行94:
  
 
http://pcboy.dip.jp/xoopscube/modules/xpress/?p=677
 
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エラー==
 
==timezoneエラー==
 
date.timezone = Asia/Tokyo ; /etc/php.ini
 
date.timezone = Asia/Tokyo ; /etc/php.ini

2021年12月25日 (土) 03:07時点における版

epelリポジトリ追加

sudo yum -y install epel-release

remiリポジトリ追加

centos7の場合

yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm

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

sudo service httpd stop
sudo service nginx stop
sudo service php-fpm stop
sudo service mysqld stop
sudo yum list installed | grep php-*
sudo yum list installed | grep mysql-*
sudo yum remove php-*
sudo yum remove mysql

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

sudo yum -y install php.x86_64 --enablerepo=remi --enablerepo=remi-php80
sudo yum -y install php-mbstring.x86_64 --enablerepo=remi --enablerepo=remi-php80
sudo yum -y install php-mcrypt.x86_64 --enablerepo=remi --enablerepo=remi-php80
sudo yum -y install php-devel.x86_64 --enablerepo=remi --enablerepo=remi-php80
sudo yum -y install php-mysql.x86_64 --enablerepo=remi --enablerepo=remi-php80
sudo yum -y install php-pecl-memcached.x86_64 --enablerepo=remi --enablerepo=remi-php80
sudo yum -y install php-gd.x86_64 --enablerepo=remi --enablerepo=remi-php80
sudo yum -y install php-opcache.x86_64 --enablerepo=remi,remi-php80 
sudo yum -y install php-fpm.x86_64 --enablerepo=remi,remi-php80 
sudo yum -y install php-pecl-xhprof.x86_64
sudo yum -y install php-pear --enablerepo=remi-php80
$ php -v
PHP 8.0.14 (cli) (built: Dec 16 2021 03:01:07) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.14, Copyright (c) Zend Technologies
   with Zend OPcache v8.0.14, Copyright (c), by Zend Technologies

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

--enablerepo=remi

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

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

php8.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

php8のphp_mecabエラー対応方法

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

php8のxhprofエラー対応方法

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

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

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

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

xhprof_enable();実行後、

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

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

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

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

cactiのphp8対応

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

  • その1

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

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

timezoneエラー

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