Home > Article > Backend Development > php7 installation guide (windows) opening zend opcache
What is zend opcache?
Zend OPcache provides faster PHP execution through opcode caching and optimization. It stores precompiled script files in shared memory for later use, thus avoiding the time consumption of reading code from disk and compiling it. At the same time, it also applies some code optimization modes to make the code execute faster.
When the interpreter completes the analysis of the script code, it generates intermediate codes that can be run directly, also called operation codes (Operate Code, opcode). The purpose of Opcode cache is to avoid repeated compilation and reduce CPU and memory overhead. If the performance bottleneck of dynamic content lies not in CPU and memory, but in I/O operations, such as the disk I/O overhead caused by database queries, then the performance improvement of opcode cache is very limited. But since opcode cache can reduce CPU and memory overhead, this is always a good thing!
Modern opcode caches (Optimizer, APC2.0, others) use shared memory for storage and can execute files directly from them without having to "deserialize" the code before execution. This results in significant performance speedups, often lower overall server memory consumption, and few downsides.
Open opcahe
Modify php.ini search: "[opcache]"
Add the following code (or change it on the original basis):
zend_extension = php_opcache.dll opcache.enable=1 opcache.enable_cli=1 opcache.memory_consumption=128 opcache.max_accelerated_files=2000
Description of the functions of several important parameters:
opcache.enable=1 //开启opcache opcache.enable_cli=1 //是否在CLI(即命令行时)启用opcache opcache.memory_consumption=128 //共享内存的大下 可以根据项目大小和服务器配置自行调整 opcache.max_accelerated_files=2000//最大缓存文件个数
After setting, just restart apache. Open phpinfo and observe the changes:
# proves that zend opcache has been successfully opened. After testing, the effect is obvious (because the number of compilations is reduced and the disk IO overhead is reduced), it is highly recommended that everyone turn it on.
Related recommendations: "PHP7 Tutorial"
##
The above is the detailed content of php7 installation guide (windows) opening zend opcache. For more information, please follow other related articles on the PHP Chinese website!