一,測試是否開啟jit?
[liuhongdi@img ~]$ more jit.php
<?php
var_dump(opcache_get_status()['jit']);
?>
報錯:
[liuhongdi@img ~]$ /usr/local/soft/php8.2.5/bin/php jit.php
PHP Fatal error: Uncaught Error: Call to undefined function opcache_get_status() in /home/liuhongdi/jit.php:2
Stack trace:
#0 {main}
thrown in /home/liuhongdi/jit.php on line 2
二,配置jit
[root@img etc]# vi php.ini
1,編輯內容:
在[opcache]一欄下增加四行
opcache.enable=1
opcache.enable_cli=1
opcache.jit_buffer_size=128M
opcache.jit=1255
2,Dynamic Extensions一欄下面:
把zend_extension=opcache一行取消註釋
如下:
;zend_extension=opcache
zend_extension=opcache
三,測試效果:
[root@img etc]# /usr/local/soft/php8.2.5/bin/php /home/liuhongdi/jit.php
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(134215280)
}
如enabled和on兩項的值為true,則表示jit已開啟
四,檢視php版本:
[liuhongdi@img ~]$ /usr/local/soft/php8.2.5/bin/php -v
PHP 8.2.5 (cli) (built: May 10 2023 14:51:39) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.5, Copyright (c) Zend Technologies
with Zend OPcache v8.2.5, Copyright (c), by Zend Technologies