facebook twitter hatena line email

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

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(apache,mysql,nginxのサービス停止&アンインストール)
 
行3: 行3:
 
==remiリポジトリ追加==
 
==remiリポジトリ追加==
 
  cd /usr/local/src
 
  cd /usr/local/src
 
centos6の場合
 
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
 
sudo rpm -Uvh remi-release-6*.rpm
 
  
 
centos7の場合
 
centos7の場合
行72: 行68:
 
php-pecl-xhprofはphp7非対応なので、飛ばす
 
php-pecl-xhprofはphp7非対応なので、飛ばす
 
  sudo yum -y install php-pecl-xhprof.x86_64
 
  sudo yum -y install php-pecl-xhprof.x86_64
 
==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エラー対応方法===
 
===php7のphp_mecabエラー対応方法===
行117: 行74:
 
===php7のxhprofエラー対応方法===
 
===php7のxhprofエラー対応方法===
 
[[php/速度改善/XHProf/php7]] [ショートカット]
 
[[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
 

2026年4月5日 (日) 01:36時点における最新版

epelリポジトリ追加

sudo yum -y install epel-release

remiリポジトリ追加

cd /usr/local/src

centos7の場合

wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
rpm -Uvh 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

remi更新

/etc/yum.repos.d/CentOS-Base.repo

[base]
name=CentOS-7.9.2009 - Base
baseurl=http://vault.centos.org/7.9.2009/os/$basearch/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[updates]
name=CentOS-7.9.2009 - Updates
baseurl=http://vault.centos.org/7.9.2009/updates/$basearch/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[extras]
name=CentOS-7.9.2009 - Extras
baseurl=http://vault.centos.org/7.9.2009/extras/$basearch/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
sudo yum clean all
sudo yum makecache

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

sudo yum -y install php.x86_64 --enablerepo=remi --enablerepo=remi-php74
sudo yum -y install php-mbstring.x86_64 --enablerepo=remi --enablerepo=remi-php74
sudo yum -y install php-mcrypt.x86_64 --enablerepo=remi --enablerepo=remi-php74
sudo yum -y install php-devel.x86_64 --enablerepo=remi --enablerepo=remi-php74
sudo yum -y install php-mysql.x86_64 --enablerepo=remi --enablerepo=remi-php74
sudo yum -y install php-pecl-memcached.x86_64 --enablerepo=remi --enablerepo=remi-php74
sudo yum -y install php-gd.x86_64 --enablerepo=remi --enablerepo=remi-php74
sudo yum -y install php-opcache.x86_64 --enablerepo=remi,remi-php74 
sudo yum -y install php-fpm.x86_64 --enablerepo=remi,remi-php74 
sudo yum -y install php-pear --enablerepo=remi-php74
$ 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

php-pecl-xhprofはphp7非対応なので、飛ばす

sudo yum -y install php-pecl-xhprof.x86_64

php7のphp_mecabエラー対応方法

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

php7のxhprofエラー対応方法

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