PHP Apache 上未加载 opcache 预加载

PHP opcache preload is not loaded on Apache

我正在使用 Apache/2.4.29 和 PHP 7.4.5 作为模块。

Apache 和 PHP 配置为 lito 作为用户。

具有 PHP 设置的虚拟主机配置:

php_admin_value opcache.enabled 1
php_admin_value opcache.preload /home/lito/www/preload.php
php_admin_value opcache.preload_user lito

phpinfo 显示 opcache 配置:

opcache.enable On
opcache.preload /home/lito/www/preload.php
opcache.preload_user lito

apache 日志中没有错误。

apache 重启后 opcache_get_status 没有任何与预加载状态相关的键 (preload_statistics) 并且只有一个脚本被预加载 (当前 phpinfo.php):

Array
(
    [opcache_enabled] => 1
    [cache_full] => 
    [restart_pending] => 
    [restart_in_progress] => 
    [memory_usage] => Array
        (
            [used_memory] => 9168872
            [free_memory] => 125047784
            [wasted_memory] => 1072
            [current_wasted_percentage] => 0.00079870223999023
        )

    [interned_strings_usage] => Array
        (
            [buffer_size] => 6291008
            [used_memory] => 522888
            [free_memory] => 5768120
            [number_of_strings] => 10969
        )

    [opcache_statistics] => Array
        (
            [num_cached_scripts] => 1
            [num_cached_keys] => 1
            [max_cached_keys] => 16229
            [hits] => 1
            [start_time] => 1587378881
            [last_restart_time] => 0
            [oom_restarts] => 0
            [hash_restarts] => 0
            [manual_restarts] => 0
            [misses] => 3
            [blacklist_misses] => 0
            [blacklist_miss_ratio] => 0
            [opcache_hit_rate] => 25
        )

    [scripts] => Array
        (
            [/home/lito/www/phpinfo.php] => Array
                (
                    [full_path] => /home/lito/www/phpinfo.php
                    [hits] => 0
                    [memory_consumption] => 1040
                    [last_used] => Mon Apr 20 12:39:15 2020
                    [last_used_timestamp] => 1587379155
                    [timestamp] => 1587378955
                )
        )
)

在使用 PHP 作为模块(没有自定义 php.ini)的 Apache 上预加载 opcache 不可用?

谢谢!

更新: 已测试在 /etc/php/7.4/apache2/php.ini 上添加预加载文件并且工作正常。

类似(对于带 php-fpm 的 nginx):https://bugs.php.net/bug.php?id=79043#1578412872

As far as I can tell, it looks like preloading is not in effect when configured this way.

来自 PHP 核心开发人员的回答:

yes, as preloading happens during early server startup, enabling it through php_admin_value does not work.