PHP8.0をCentOS7に導入します。
Remiレポジトリの追加
# yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm
PHP8.0のインストール
JITを使いたいのでopcache拡張機能も忘れずにインストールします。
他必要な拡張機能諸々も。
# yum install -y php80 php80-php-fpm php80-php-mbstring php80-php-pdo php80-php-mysql php80-php-opcache
JITの有効化
JITはデフォルトでバッファサイズが0になっており使えないので、バッファサイズを指定して有効化します。
/etc/opt/remi/php80/php.d/10-opcache.ini
の最後に以下を追記
opcache.jit_buffer_size=100M
メモリexecuteの許可(SELinux環境のみ)
SELinux環境にてPHPを実行しようとすると以下のようなエラーになります。
mprotect() failed [13] Permission denied
httpd_tに対しhttpd_tmpfs_tのexecuteが許可されていないことが原因ですので、カスタムポリシーを作成してロードします。
(setools等インストールしていない場合は以下のコマンドで入れる)
# yum install -y setools selinux-policy-devel
# echo '(allow httpd_t httpd_tmpfs_t (file (execute)))' > httpd_jit.cil
# semanage -i httpd_jit.cil
動作確認
# php80 -v
PHP 8.0.11 (cli) (built: Sep 21 2021 17:07:44) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.11, Copyright (c) Zend Technologies
with Zend OPcache v8.0.11, Copyright (c), by Zend Technologies
# php80 -i | grep opcache.jit
opcache.jit => tracing => tracing
opcache.jit_bisect_limit => 0 => 0
opcache.jit_blacklist_root_trace => 16 => 16
opcache.jit_blacklist_side_trace => 8 => 8
opcache.jit_buffer_size => 100M => 100M
opcache.jit_debug => 0 => 0
opcache.jit_hot_func => 127 => 127
opcache.jit_hot_loop => 64 => 64
opcache.jit_hot_return => 8 => 8
opcache.jit_hot_side_exit => 8 => 8
opcache.jit_max_exit_counters => 8192 => 8192
opcache.jit_max_loop_unrolls => 8 => 8
opcache.jit_max_polymorphic_calls => 2 => 2
opcache.jit_max_recursive_calls => 2 => 2
opcache.jit_max_recursive_returns => 2 => 2
opcache.jit_max_root_traces => 1024 => 1024
opcache.jit_max_side_traces => 128 => 128
opcache.jit_prof_threshold => 0.005 => 0.005
バージョン−表示でwith Zend OPcache
になっていること、およびjit_buffer_size
が0より大であることを確認します。
参考
CentOS7にPHP8.0をyumインストールする方法 | PHP Junkie
https://php-junkie.net/env/php8/
Chapter 7. Writing a custom SELinux policy Red Hat Enterprise Linux 8 | Red Hat Customer Portal
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/using_selinux/writing-a-custom-selinux-policy_using-selinux