php7.4 opcache.preload-fpm启动时出错

我正在升级到php7.4,并希望利用新的opcache预加载功能。

service php7.4-fpm start出现以下错误:

NOTICE: PHP message: PHP Warning:  PHP Startup: failed to open stream: Permission denied in Unknown on line 0
NOTICE: PHP message: PHP Fatal error:  PHP Startup: Failed opening required '/mnt/a/b/c/opcachePreload.php' (include_path='.:/usr/share/php:/mnt/a/b/c:/mnt/a/b/d') in Unknown on line 0
php7.4-fpm.service: Main process exited,code=exited,status=70/n/a
Failed to start The PHP 7.4 FastCGI Process Manager.

我的fpm/php.ini包含以下操作缓存设置:

include_path              = ".:/usr/share/php:/mnt/a/b/c"

opcache.save_comments           = 1
opcache.max_accelerated_files   = 7963
opcache.interned_strings_buffer = 16
opcache.fast_shutdown           = 1
opcache.revalidate_freq         = 0

opcache.validate_timestamps     = 0
opcache.memory_consumption      = 128
opcache.preload                 = /mnt/a/b/c/opcachePreload.php
opcache.preload_user            = www-data

我尝试让opcachePreload.php只包含<?php,并且错误仍然发生,通常它包含类似这样的东西,并且在数组中有一些绝对路径:

<?php
declare(strict_types=1);

$scriptsArr = [
    'path','path',];
foreach ($scriptsArr as $fileStr) {
    opcache_compile_file($fileStr);
}

我已经尝试了一系列不同级别的文件权限(0600、0700、0770、0777,由root拥有),当前ls -l /mnt/a/b/c/opcachePreload.php显示:

-rwxrwxrwx 1 www-data www-data 336 Dec 26 15:11 /mnt/a/b/c/opcachePreload.php

是文件许可问题,还是配置冲突,还是php7.4错误,还是其他?

opcache.preload被解释为某种相对路径而不是绝对路径吗? (我已经尝试过opcache.preload = ./opcachePreload.php

我还能尝试什么?

lyc417402731 回答:php7.4 opcache.preload-fpm启动时出错

尝试将opcachePreload.php放入/var/www/html内,并将opcache.preload更改为

opcache.preload = /var/www/html/opcachePreload.php

如果可以,那么www-data无权访问/mnt/a/b/c/中的文件

本文链接:https://www.f2er.com/2856040.html

大家都在问