4

我正在升级到 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包括以下 opcache 设置:

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

我还能尝试什么?

4

1 回答 1

4

例如,尝试将您的opcachePreload.php内部/var/www/html更改opcache.preload

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

如果可行,则www-data无权访问其中的文件/mnt/a/b/c/

于 2019-12-27T07:01:15.363 回答