gpt4 book ai didi

php - 当存在预加载文件时 Apache 不会启动

转载 作者:行者123 更新时间:2023-12-02 13:45:09 25 4
gpt4 key购买 nike

我刚刚安装了 Opcache ,一切似乎都工作正常,但是当我在 php.iniopcache.preload 中添加 PHP 文件时并重新启动 Apache 服务器无法启动。另一方面,在 CLI SAPI 中预加载工作正常!

当我注释掉 opcache.preload 并重新启动时,Apache 服务器可以正常工作

由于这个问题没有发出任何错误,我查找了 Apache error_log 文件,结果发现问题是我没有定义 opcahe 预加载用户

Fatal Error "opcache.preload_user" has not been defined

但是根据PHP documentation

Preloading code as root is not allowed for security reasons. This directive facilitates to let the preloading to be run as another user.

我正在我的个人计算机上运行 Ubuntu,WSL

那么请指导我该怎么办?我应该添加什么用户?

最佳答案

Ubuntu 上 Web 服务器的默认用户是 www-data

您需要做的就是

opcache.preload_user=www-data

如果你想检查预加载

var_dump(opcache_get_status()['preload_statistics']); 

它将列出所有预加载的文件以及它们消耗的内存

至于为什么我没有定义预加载用户时Apache拒绝启动?

其实我也不知道为什么。这可能是一个错误,但不确定。

<小时/>

虽然 PHP 文档中的声明并不完整,但请注意:

Preloading under root is not allowed by default, but explicituse of opcache.preload_user=root is allowed

关于php - 当存在预加载文件时 Apache 不会启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59322552/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com