CentOS7にPHP7.2とrunkit7をインストールする手順
カテゴリ:PHP
CentOS7にPHP7.2とrunkit7をインストールしたので手順を記録として残しておきます。PHP7.2のインストール
# yum install epel-release # rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm # yum install --enablerepo=remi,remi-php72 php php-devel php-mbstring php-pdo php-gd php-xml php-mcrypt
runkit7のインストール
# yum install http://rpms.remirepo.net/enterprise/7/remi/x86_64//php72-php-pecl-runkit7-2.1.0-1.el7.remi.x86_64.rpm # echo "extension=/opt/remi/php72/root/usr/lib64/php/modules/runkit.so" >> /etc/php.ini
参考php72-php-pecl-runkit7-2.1.0-1.el7.remi.x86_64.rpm
ファイルパス
/etc/opt/remi/php72/php.d/40-runkit.ini
/opt/remi/php72/root/usr/lib64/php/modules/runkit.so
/opt/remi/php72/root/usr/share/doc/pecl/runkit7/PROPERTY_MANIPULATION.md
/opt/remi/php72/root/usr/share/doc/pecl/runkit7/README.md
/opt/remi/php72/root/usr/share/licenses/php72-php-pecl-runkit7-2.1.0/LICENSE
/var/opt/remi/php72/lib/pear/pkgxml/php72-php-pecl-runkit7.xml
有効化の確認
phpinfoで以下の表示項目があれば成功です。

注意
phpinfoではSandbox Supportが利用不可となっていますが、サンドボックスはPHPをスレッドセーフとしてインストールしなければ利用できません。
PHPをスレッドセーフとしてインストールするためにはソースを--enable-maintainer-ztsオプションを付与してconfigureする必要があります。
スレッドセーフ版PHPのインストール
以下のコマンドでスレッドセーフかを確認します。disabledであればスレッドセーフではありません。
# php -i | grep "Thread Safety" Thread Safety => disabled
スレッドセーフではない場合、以下の手順でPHP7.2のソースを--enable-maintainer-ztsオプションを付与してconfigureしてZTS(Zend Thread Safe)としてインストールします。
PHP7.2のソースをダウンロード、解凍します。
# wget https://www.php.net/distributions/php-7.2.22.tar.gz # tar zxvf php-7.2.22.tar.gz
スレッドセーフを有効にしてPHPをインストールします。
# cd php-7.2.22 # ./configure --enable-debug --enable-maintainer-zts --enable-cgi --enable-cli --enable-runkit7-feature --prefix=/usr/local/php --with-apxs2=/usr/bin/apxs # make # make test # make install
注意もしapxsが見つからずconfigureに失敗する場合、yumでhttpd-develをインストールしましょう。
# make install Installing PHP SAPI module: apache2handler /usr/lib64/httpd/build/instdso.sh SH_LIBTOOL='/usr/lib64/apr-1/build/libtool' libphp7.la /usr/lib64/httpd/modules /usr/lib64/apr-1/build/libtool --mode=install install libphp7.la /usr/lib64/httpd/modules/ libtool: install: install .libs/libphp7.so /usr/lib64/httpd/modules/libphp7.so libtool: install: install .libs/libphp7.lai /usr/lib64/httpd/modules/libphp7.la libtool: install: warning: remember to run `libtool --finish /root/php-7.2.22/libs' chmod 755 /usr/lib64/httpd/modules/libphp7.so [activating module `php7' in /etc/httpd/conf/httpd.conf] Installing shared extensions: /usr/local/php/lib/php/extensions/debug-zts-20170718/ Installing PHP CLI binary: /usr/local/php/bin/ Installing PHP CLI man page: /usr/local/php/php/man/man1/ Installing phpdbg binary: /usr/local/php/bin/ Installing phpdbg man page: /usr/local/php/php/man/man1/ Installing PHP CGI binary: /usr/local/php/bin/ Installing PHP CGI man page: /usr/local/php/php/man/man1/ Installing build environment: /usr/local/php/lib/php/build/ Installing header files: /usr/local/php/include/php/ Installing helper programs: /usr/local/php/bin/ program: phpize program: php-config Installing man pages: /usr/local/php/php/man/man1/ page: phpize.1 page: php-config.1 Installing PEAR environment: /usr/local/php/lib/php/ [PEAR] Archive_Tar: upgrade to a newer version (1.4.7 is not newer than 1.4.7) [PEAR] Console_Getopt: upgrade to a newer version (1.4.2 is not newer than 1.4.2) [PEAR] Structures_Graph: upgrade to a newer version (1.1.1 is not newer than 1.1.1) [PEAR] XML_Util: upgrade to a newer version (1.4.3 is not newer than 1.4.3) [PEAR] PEAR: upgrade to a newer version (1.10.9 is not newer than 1.10.9) /root/php-7.2.22/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin ln -s -f phar.phar /usr/local/php/bin/phar Installing PDO headers: /usr/local/php/include/php/ext/pdo/
ZTSである事を確認します。
# /usr/local/bin/php -v PHP 7.2.22 (cli) (built: Sep 14 2019 23:56:09) ( ZTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
スレッドセーフが有効である事を確認します。
# /usr/local/bin/php -i | grep "Thread Safety" Thread Safety => enabled
runkit7をソースからインストール
github.comからソースをダウンロードしてインストールします。
# git clone https://github.com/runkit7/runkit7.git # cd runkit7 # phpize # ./configure # make # make test # make install
make install時にrunkit7.soのパスを確認します。
# make install Installing shared extensions: /usr/local/lib/php/extensions/debug-zts-20170718/ # ls /usr/local/lib/php/extensions/debug-zts-20170718/ opcache.a opcache.so runkit7.so
runkit7.soを/usr/local/lib/php/extensions配下にコピーします。
# cp /usr/local/lib/php/extensions/debug-zts-20170718/runkit7.so /usr/local/lib/php/extensions/no-debug-zts-20170718/
runkit7.soの拡張をphp.iniに追記します。
# echo "extension=runkit7.so" >> /usr/local/lib/php.ini
Apacheでlibphp7.soを読み込むように設定
libphp7.soのシンボリックリンクを/etc/httpd/modules/に作成します。
ln -s /usr/lib64/httpd/modules/libphp7.so /etc/httpd/modules/
/etc/httpd/conf/httpd.confに以下を追加します。
LoadModule php7_module modules/libphp7.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
Apacheを再起動します。
# systemctl restart httpd
公開日時:2019年09月14日 22:49:09