Home > Backend Development > PHP7 > body text

php7 installation guide (windows) opening zend opcache

藏色散人
Release: 2023-02-17 12:16:02
forward
4431 people have browsed it


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
Copy after login

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//最大缓存文件个数
Copy after login

After setting, just restart apache. Open phpinfo and observe the changes:

php7 installation guide (windows) opening zend opcache

# 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!

Related labels:
source:hcoder.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template