我使用 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
,它工作正常。