我们使用的是 PHP + FPM 8.2 + OPCache。以前我们使用https://www.repairrar.com/opcache.php来检查它的状态。但是今天它返回一个空页面。虽然它显示一个空页面,但我查看页面源代码发现它的内容大约有 3.3MB,但它们就是不显示在浏览器中。我尝试了 Chrome 和 FireFox,但显示的内容为空。
我还编写了一个小的 PHP 文件
<?php
echo '<pre>' , var_dump(opcache_get_status(false)) , '</pre>';
?>
当访问https://www.repairrar.com/opcache-get-status.php时,它显示 OpCache 已启用并正常运行:
array(8) {
["opcache_enabled"]=>
bool(true)
["cache_full"]=>
bool(false)
["restart_pending"]=>
bool(false)
["restart_in_progress"]=>
bool(false)
["memory_usage"]=>
array(4) {
["used_memory"]=>
int(446911376)
["free_memory"]=>
int(626183176)
["wasted_memory"]=>
int(647272)
["current_wasted_percentage"]=>
float(0.0602819025516510009765625)
}
["interned_strings_usage"]=>
array(4) {
["buffer_size"]=>
int(134217728)
["used_memory"]=>
int(52098200)
["free_memory"]=>
int(82119528)
["number_of_strings"]=>
int(242556)
}
["opcache_statistics"]=>
array(13) {
["num_cached_scripts"]=>
int(10741)
["num_cached_keys"]=>
int(15444)
["max_cached_keys"]=>
int(130987)
["hits"]=>
int(167134669)
["start_time"]=>
int(1733489514)
["last_restart_time"]=>
int(0)
["oom_restarts"]=>
int(0)
["hash_restarts"]=>
int(0)
["manual_restarts"]=>
int(0)
["misses"]=>
int(11569)
["blacklist_misses"]=>
int(0)
["blacklist_miss_ratio"]=>
float(0)
["opcache_hit_rate"]=>
float(99.99307851607164820961770601570606231689453125)
}
["jit"]=>
array(7) {
["enabled"]=>
bool(false)
["on"]=>
bool(false)
["kind"]=>
int(5)
["opt_level"]=>
int(4)
["opt_flags"]=>
int(6)
["buffer_size"]=>
int(0)
["buffer_free"]=>
int(0)
}
}
下面是 php.ini 文件(我检查了更改历史记录,自 Opcache.php 返回可见内容以来它就没有改变过):
; cPanel-generated php ini directives, do not edit
; Manual editing of this file may result in unexpected behavior.
; To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
; For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
allow_url_fopen = On
allow_url_include = Off
display_errors = Off
enable_dl = Off
file_uploads = On
max_execution_time = 1000
max_input_time = 1000
max_input_vars = 1000
memory_limit = 512M
post_max_size = 64M
session.gc_maxlifetime = 2880
#session.save_path = "/var/cpanel/php/sessions/ea-php72"
upload_max_filesize = 64M
zlib.output_compression = Off
session.save_path = "/var/cpanel/php/sessions/ea-php82"
; The gloabal 10-opcahce.ini has already enable opcache, so it is not necessary to enable it here again.
; Enable opcache here will cause 'Zend OPcache can't be temporary enabled' warning in PHP. So the following
; line is commented out
; opcache.enable=1