我在Ubuntu 14.04上有一个LAMP系统
我在路径/etc/php5/apache2/php.ini的php.ini中进行了更改我在php.ini中进行了以下更改
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=120
我放置opcache.enable_cli=1的原因是因为我在php -i中得到了以下错误
Opcode Caching => Disabled
Optimization => Disabled
Startup Failed => Opcode Caching is disabled for CLI
opcache.enable => On => On
opcache.enable_cli => Off => Off
在输入opcache.enable_cli=1之后,我在php -i中得到了以下内容
Zend OPcache
Opcode Caching => Up and Running
Optimization => Enabled
Startup => OK
Shared memory model => mmap
Cache hits => 0
Cache misses => 0
Used memory => 10707944
Free memory => 123509784
Wasted memory => 0
Cached scripts => 0
Cached keys => 0
Max keys => 3907
OOM restarts => 0
Hash keys restarts => 0
Manual restarts => 0
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 => On => On
opcache.enable_file_override => Off => Off
opcache.error_log => no value => no value
opcache.fast_shutdown => 1 => 1
opcache.file_update_protection => 2 => 2
opcache.force_restart_timeout => 180 => 180
opcache.inherited_hack => On => On
opcache.interned_strings_buffer => 8 => 8
opcache.load_comments => 1 => 1
opcache.log_verbosity_level => 1 => 1
opcache.max_accelerated_files => 2500 => 2500
opcache.max_file_size => 0 => 0
opcache.max_wasted_percentage => 5 => 5
opcache.memory_consumption => 128 => 128
opcache.optimization_level => 0xFFFFFFFF => 0xFFFFFFFF
opcache.preferred_memory_model => no value => no value
opcache.protect_memory => 0 => 0
opcache.restrict_api => no value => no value
opcache.revalidate_freq => 90 => 90
opcache.revalidate_path => Off => Off
opcache.save_comments => 1 => 1
opcache.use_cwd => On => On
opcache.validate_timestamps => On => On
Opcache正在运行,但它没有缓存任何内容。在第一次加载页面,然后在90秒内刷新页面后,我看到一个不同的页面
发布于 2015-08-11 15:29:53
你误解了什么是opcache。PHP文件只是纯文本。它们不是机器代码。因此PHP必须解析文本并生成机器码(操作码,或简称操作码)。一旦它有了这个操作码,它就可以运行你的程序。
Opcache只是存储操作码。当底层代码变化不大时,它有助于节省开销。
您正在谈论的是类似于output caching的东西,其中web服务器存储它发送给客户端的内容。
https://stackoverflow.com/questions/31945593
复制