1.下载php8
链接: https://pan.baidu.com/s/10C4U2GPnLXb_KZLLmbY6dw 密码: 9chu
2.解压:
tar -zxvf php-8.0.0.tar.gz
3.配置、安装
./configure --prefix=/usr/local/php8 --with-config-file-path=/usr/local/php8/etc \
--with-curl --with-freetype --enable-gd --with-jpeg --with-gettext --with-kerberos --with-libdir=lib64 --with-libxml \
--with-mysqli --with-openssl --with-pdo-mysql --with-pdo-sqlite --with-pear --enable-sockets --with-mhash --with-ldap-sasl \
--with-xsl --with-zlib --with-zip -with-bz2 --with-iconv --enable-fpm --enable-pdo --enable-bcmath --enable-mbregex \
--enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem \
--enable-xml --enable-sysvsem --enable-cli --enable-opcache --enable-intl --enable-calendar --enable-static --enable-mysqlnd
其中可能报
No package ‘sqlite3’ found
解决方法:
yum install sqlite-devel
No package ‘icu-uc’ found
解决方法:
yum install libicu-devel
No package ‘oniguruma’ found
解决方法:
yum install oniguruma-devel
No package ‘libzip’ found
解决方法:
yum install libzip-devel
Requested ‘libzip >= 0.11’ but version of libzip is 0.10.1
解决方法:
下载libzip:
链接: https://pan.baidu.com/s/1OJJFHMM6C-f1WSa5D_ppyw 密码: 9km1
tar -zxvf libzip-1.2.0.tar.gz
cd libzip-1.2.0
./configure
make && make install
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/"
如果出现下面则表示配置成功:
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+
Thank you for using PHP.
测试是否安装成功:
/usr/local/php8/bin/php --version
配置:
cp php.ini-production /usr/local/php8/etc/php.ini
cd /usr/local/php8/etc/php-fpm.d/
cp www.conf.default www.conf
cd /usr/local/php8/etc/
cp php-fpm.conf.default php-fpm.conf
启用php8的新特性:
编辑php.ini
启用opcache
opcache.enable=1
opcache.enable_cli=1
;启用jit,并指定jit的buffer
opcache.jit_buffer_size=128M
opcache.jit=1255
;zend对opcache模块的引用,要打开
zend_extension=opcache
然后重启
查看phpinfo信息
需要能看到zend opcache一项,
否则opcache未生效
注意看JIT中的一项,需要值为On
新建jit.php
<?php
var_dump(opcache_get_status()['jit']);
如下输出:
array(7) {
["enabled"]=> bool(true)
["on"]=> bool(true)
["kind"]=> int(5)
["opt_level"]=> int(5)
["opt_flags"]=> int(6)
["buffer_size"]=> int(134217712)
["buffer_free"]=> int(134215440)
}
注意:如果enabled和on两项的值都为true,
则表示jit已开启