OpCache-Magento2的推荐配置


10

我正在使用Magento 2堆栈,正在重用某些Magento 1 OpCache配置。我已经了解到,现在我们需要启用注释,但是我很确定其他值可以改进,因此这是我当前的配置:

[opcache]
opcache.enable=1
opcache.enable_cli=0
opcache.memory_consumption=256
opcache.interned_strings_buffer=12
opcache.max_accelerated_files=65406 // thanks Mage2.Pro!
;opcache.max_wasted_percentage=5
;opcache.use_cwd=1
opcache.validate_timestamps=0
;opcache.revalidate_freq=2
;opcache.revalidate_path=0
;opcache.save_comments=0
;opcache.load_comments=0
opcache.fast_shutdown=1
opcache.enable_file_override=1
;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=/var/log/php5/php5-opcache.error.log
opcache.log_verbosity_level=3
;opcache.preferred_memory_model=
;opcache.protect_memory=0

注意: 为了使它对所有人有用,我将在问题中(打开时)编辑配置块,以使其对每个人都有用,并且避免重复建议,如果对此有任何疑问或表示违反站点规则,让我知道。


为什么不为CLI启用opcache?
MagePsycho

Answers:


13

opcache.max_accelerated_files=16000对于Magento 2来说肯定是比较低的。
find . -type f -print | xargs grep "<?php" | wc -l30736可以安装Magento 2(带有在var/generation文件夹中生成的代码以及安装的一些外部扩展名)。
我建议设置opcache.max_accelerated_files65406您的服务器是否安装了单个Magento 2,并且没有其他PHP站点。
如果服务器上有多个PHP站点,请考虑该值130986


0

我还建议包括以下我相信在php7中添加的设置

; Allows calling OPcache API functions only from PHP scripts which path is
; started from specified string. The default "" means no restriction
;opcache.restrict_api=

; Mapping base of shared memory segments (for Windows only). All the PHP
; processes have to map shared memory into the same address space. This
; directive allows to manually fix the "Unable to reattach to base address"
; errors.
;opcache.mmap_base=

; Enables and sets the second level cache directory.
; It should improve performance when SHM memory is full, at server restart or
; SHM reset. The default "" disables file based caching.
;opcache.file_cache=

; Enables or disables opcode caching in shared memory.
;opcache.file_cache_only=0

; Enables or disables checksum validation when script loaded from file cache.
;opcache.file_cache_consistency_checks=1

; Implies opcache.file_cache_only=1 for a certain process that failed to
; reattach to the shared memory (for Windows only). Explicitly enabled file
; cache is required.
;opcache.file_cache_fallback=1

; Enables or disables copying of PHP code (text segment) into HUGE PAGES.
; This should improve performance, but requires appropriate OS configuration.
;opcache.huge_code_pages=1
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.