简体   繁体   中英

PHP opcache preload is not loaded on Apache

I'm using Apache/2.4.29 with PHP 7.4.5 as module.

Apache and PHP are configured with lito as user.

Virtualhost configuration with PHP settings:

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

phpinfo show opcache configuration:

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

No errors on apache log.

After apache restart opcache_get_status haven't any key related with preload status ( preload_statistics ) and there are only one script preloaded (current 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
                )
        )
)

Is not available opcache preload on Apache with PHP as module (without a custom php.ini)?

Thanks!

UPDATE: Tested adding preload file on /etc/php/7.4/apache2/php.ini and it works fine.

Similar (for nginx with php-fpm): 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.

Answer from PHP core dev:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM