drudfe0446838 2018-10-15 19:10 采纳率: 0%
浏览 383

OPCache已启用,但php -i显示已禁用

I installed NextCloud and in the summary window it keeps telling me that my OPCache is not enabled. I have enabled it and I am seeing conflicting information about if it really is enabled or not.

Ubuntu 18.04.1 | PHP 7.2.11-2

$ sudo cat /etc/php/7.2/apache2/php.ini | grep opcache
[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
;opcache.max_wasted_percentage=5
;opcache.use_cwd=1
;opcache.validate_timestamps=1
opcache.revalidate_freq=1
;opcache.revalidate_path=0
opcache.save_comments=1
;opcache.enable_file_override=0
;opcache.optimization_level=0xffffffff
;opcache.inherited_hack=1
;opcache.dups_fix=0
;opcache.blacklist_filename=
;opcache.max_file_size=0
;opcache.consistency_checks=0
;opcache.force_restart_timeout=180
;opcache.error_log=
;opcache.log_verbosity_level=1
;opcache.preferred_memory_model=
;opcache.protect_memory=0
;opcache.restrict_api=
;opcache.mmap_base=
;opcache.file_cache=
;opcache.file_cache_only=0
;opcache.file_cache_consistency_checks=1
; Implies opcache.file_cache_only=1 for a certain process that failed to
;opcache.file_cache_fallback=1
;opcache.huge_code_pages=1
;opcache.validate_permission=0
;opcache.validate_root=0
;opcache.opt_debug_level=0

Here is my output of php -i:

$ php -i
Zend OPcache

Opcode Caching => Disabled
Optimization => Disabled
SHM Cache => Enabled
File Cache => Disabled
Startup Failed => Opcode Caching is disabled for CLI

Directive => Local Value => Master Value
opcache.blacklist_filename => no value => no value
opcache.consistency_checks => 0 => 0
opcache.dups_fix => Off => Off
opcache.enable => On => On
opcache.enable_cli => Off => Off
opcache.enable_file_override => Off => Off
opcache.error_log => no value => no value
opcache.file_cache => no value => no value
opcache.file_cache_consistency_checks => 1 => 1
opcache.file_cache_only => 0 => 0
opcache.file_update_protection => 2 => 2
opcache.force_restart_timeout => 180 => 180
opcache.huge_code_pages => Off => Off
opcache.inherited_hack => On => On
opcache.interned_strings_buffer => 8 => 8
opcache.lockfile_path => /tmp => /tmp
opcache.log_verbosity_level => 1 => 1
opcache.max_accelerated_files => 10000 => 10000
opcache.max_file_size => 0 => 0
opcache.max_wasted_percentage => 5 => 5
opcache.memory_consumption => 128 => 128
opcache.opt_debug_level => 0 => 0
opcache.optimization_level => 0x7FFFBFFF => 0x7FFFBFFF
opcache.preferred_memory_model => no value => no value
opcache.protect_memory => 0 => 0
opcache.restrict_api => no value => no value
opcache.revalidate_freq => 2 => 2
opcache.revalidate_path => Off => Off
opcache.save_comments => 1 => 1
opcache.use_cwd => On => On
opcache.validate_permission => Off => Off
opcache.validate_root => Off => Off
opcache.validate_timestamps => On => On

Then finally, looking at a phpinfo() generated page, I see it loading the php.ini file from the correct one I have edited from the first block. The only additional .ini file it is loading is from the mods-available folder:

$ sudo cat /etc/php/7.2/mods-available/opcache.ini
; configuration for php opcache module
; priority=10
zend_extension=/usr/lib/php/20170718/opcache.so

There isn't any of the settings in that file, so the only file I see those settings in is the php.ini file, which is the same one being loaded from phpinfo(). These settings have been set for a while too, I am just now noticing they weren't taking affect. So the apache server has been rebooted with these settings saved. What am I missing here?

Edit: Here are some screenshots of the phpinfo() screen for further clarification: phpinfo() 1

phpinfo() 2

  • 写回答

2条回答 默认 最新

  • dopnpoh056622 2018-10-15 19:33
    关注

    I don't have enough reputation point to add this as a comment, so I'm adding it as an answer. Can you please run php -a and then run the following command to see what it says:

    print_r(opcache_get_configuration());
    

    It should usually show something like this:

    
    Array
    (
        [directives] => Array
            (
                [opcache.enable] => 1
                [opcache.enable_cli] => 
                [opcache.use_cwd] => 1
                [opcache.validate_timestamps] => 1
                [opcache.validate_permission] => 
                [opcache.validate_root] => 
                [opcache.inherited_hack] => 1
                [opcache.dups_fix] => 
                [opcache.revalidate_path] => 
                [opcache.log_verbosity_level] => 1
                [opcache.memory_consumption] => 134217728
                [opcache.interned_strings_buffer] => 8
                [opcache.max_accelerated_files] => 10000
                [opcache.max_wasted_percentage] => 0.05
                [opcache.consistency_checks] => 0
                [opcache.force_restart_timeout] => 180
                [opcache.revalidate_freq] => 2
                [opcache.preferred_memory_model] => 
                [opcache.blacklist_filename] => 
                [opcache.max_file_size] => 0
                [opcache.error_log] => 
                [opcache.protect_memory] => 
                [opcache.save_comments] => 1
                [opcache.enable_file_override] => 
                [opcache.optimization_level] => 2147467263
                [opcache.lockfile_path] => /tmp
                [opcache.file_cache] => 
                [opcache.file_cache_only] => 
                [opcache.file_cache_consistency_checks] => 1
            )
        [version] => Array
            (
                [version] => 7.2.10-0ubuntu0.18.04.1
                [opcache_product_name] => Zend OPcache
            )
        [blacklist] => Array
            (
            )
    )
    

    if you find opcache.enable is true (as it is in this example), then it's enabled. However, it's not enabled for cli.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题