AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1168577
Accepted
alancc
alancc
Asked: 2024-12-06 11:57:06 +0800 CST2024-12-06 11:57:06 +0800 CST 2024-12-06 11:57:06 +0800 CST

Opcache.php 返回一个空白页面

  • 772

我们使用的是 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

php
  • 1 1 个回答
  • 71 Views

1 个回答

  • Voted
  1. Best Answer
    Kiyomizu
    2024-12-14T21:22:52+08:002024-12-14T21:22:52+08:00

    问题似乎出在浏览器中页面的呈现方式上,尽管内容仍然存在。您可以尝试清除浏览器缓存或禁用扩展程序,看看是否有帮助。此外,在不同的浏览器中测试页面可能会提供更多见解。如果这不起作用,请检查服务器日志中是否有任何错误或检查 PHP-FPM 和内存设置,因为可能有某些因素影响页面的呈现方式。

    您看到的是一个空白的 OPcache 页面,但是页面源仍然有内容。

    禁用输出缓冲:

    > ob_end_clean();   ob_implicit_flush(true);
    

    设置正确的内容类型:确保页面呈现为 HTML

    header('Content-Type: text/html; charset=UTF-8');
    

    启用错误报告:在脚本中启用错误报告

    ini_set('display_errors', 1);
    error_reporting(E_ALL);
    

    检查 OPcache 设置:验证 php.ini 中是否启用了 OPcache

    opcache.enable = 1
    opcache.revalidate_freq = 0
    

    清除浏览器缓存或在隐身模式下测试以避免干扰。

    运行这个基本脚本来查看输出是否有效:

    <?php
    echo "Starting...";
    var_dump(opcache_get_status(false));
    echo "Done.";
    

    确认 OPcache 已启用:php -i | grep opcache

    • 1

相关问题

  • 用户特定的 Php.ini 当 php 作为模块运行时?

  • 使 php mail() 函数在 ubuntu-server 上工作的步骤是什么?

  • Web 服务器和数据库服务器位于完全不同的位置

  • PHP 作为 CGI 还是 Apache 模块?

  • 通过 VPN 连接什么是远程服务器 IP?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve