簡體   English   中英

PHP opcache 預加載未在 Apache 上加載

[英]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?412872#157

據我所知,以這種方式配置時,預加載似乎無效。

PHP 核心開發人員的回答:

是的,因為預加載發生在早期服務器啟動期間,通過 php_admin_value 啟用它不起作用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM