search
HomeBackend DevelopmentPHP TutorialPHP optimization---opcache configuration instructions

<span>[</span><span>opcache</span><span>]</span><span>
zend_extension </span>= "G:/PHP/php-5.5.6-Win32-VC11-x64/ext/php_opcache.dll"
 
<span>;</span><span> Zend Optimizer + 的开关, 关闭时代码不再优化.</span>
opcache.enable=1
 
<span>;</span><span> Determines if Zend OPCache is enabled for the CLI version of PHP</span>
opcache.enable_cli=1
 
 
<span>;</span><span> Zend Optimizer + 共享内存的大小, 总共能够存储多少预编译的 PHP 代码(单位:MB)</span><span>
;</span><span> 推荐 128</span>
opcache.memory_c
 
<span>;</span><span> Zend Optimizer + 暂存池中字符串的占内存总量.(单位:MB)</span><span>
;</span><span> 推荐 8</span>
opcache.interned_strings_buffer=4
 
 
<span>;</span><span> 最大缓存的文件数目 200  到 100000 之间</span><span>
;</span><span> 推荐 4000</span>
opcache.max_accelerated_files=2000
 
<span>;</span><span> 内存“浪费”达到此值对应的百分比,就会发起一个重启调度.</span>
opcache.max_wasted_percentage=5
 
<span>;</span><span> 开启这条指令, Zend Optimizer + 会自动将当前工作目录的名字追加到脚本键上,</span><span>
;</span><span> 以此消除同名文件间的键值命名冲突.关闭这条指令会提升性能,</span><span>
;</span><span> 但是会对已存在的应用造成破坏.</span>
opcache.use_cwd=0
 
 
<span>;</span><span> 开启文件时间戳验证 </span>
opcache.validate_timestamps=1
 
 
<span>;</span><span> 2s检查一次文件更新 注意:0是一直检查不是关闭</span><span>
;</span><span> 推荐 60</span>
opcache.revalidate_freq=2
 
<span>;</span><span> 允许或禁止在 include_path 中进行文件搜索的优化</span><span>
;</span><span>opcache.revalidate_path=0</span><span>;</span><span> 是否保存文件/函数的注释   如果apigen、Doctrine、 ZF2、 PHPUnit需要文件注释</span><span>
;</span><span> 推荐 0</span>
opcache.save_comments=1
 
<span>;</span><span> 是否加载文件/函数的注释</span><span>
;</span><span>opcache.load_comments=1</span><span>;</span><span> 打开快速关闭, 打开这个在PHP Request Shutdown的时候会收内存的速度会提高</span><span>
;</span><span> 推荐 1</span>
opcache.fast_shutdown=1
 
<span>;</span><span>允许覆盖文件存在(file_exists等)的优化特性。</span><span>
;</span><span>opcache.enable_file_override=0</span><span>;</span><span> 定义启动多少个优化过程</span><span>
;</span><span>opcache.optimizati/span><span>;</span><span> 启用此Hack可以暂时性的解决”can’t redeclare class”错误.</span><span>
;</span><span>opcache.inherited_hack=1</span><span>;</span><span> 启用此Hack可以暂时性的解决”can’t redeclare class”错误.</span><span>
;</span><span>opcache.dups_fix=0</span><span>;</span><span> 设置不缓存的黑名单</span><span>
;</span><span> 不缓存指定目录下cache_开头的PHP文件. /png/www/example.com/public_html/cache/cache_ </span><span>
;</span><span>opcache.blacklist_filename=</span><span>;</span><span> 通过文件大小屏除大文件的缓存.默认情况下所有的文件都会被缓存.</span><span>
;</span><span>opcache.max_file_size=0</span><span>;</span><span> 每 N 次请求检查一次缓存校验.默认值0表示检查被禁用了.</span><span>
;</span><span> 由于计算校验值有损性能,这个指令应当紧紧在开发调试的时候开启.</span><span>
;</span><span>opcache.c/span><span>;</span><span> 从缓存不被访问后,等待多久后(单位为秒)调度重启</span><span>
;</span><span>opcache.force_restart_timeout=180</span><span>;</span><span> 错误日志文件名.留空表示使用标准错误输出(stderr).</span><span>
;</span><span>opcache.error_log=</span><span>;</span><span> 将错误信息写入到服务器(Apache等)日志</span><span>
;</span><span>opcache.log_verbosity_level=1</span><span>;</span><span> 内存共享的首选后台.留空则是让系统选择.</span><span>
;</span><span>opcache.preferred_memory_model=</span><span>;</span><span> 防止共享内存在脚本执行期间被意外写入, 仅用于内部调试.</span><span>
;</span><span>opcache.protect_memory=0</span></span></span>

The above introduces the configuration instructions of PHP optimization---opcache, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement
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
What are some common problems that can cause PHP sessions to fail?What are some common problems that can cause PHP sessions to fail?Apr 25, 2025 am 12:16 AM

Reasons for PHPSession failure include configuration errors, cookie issues, and session expiration. 1. Configuration error: Check and set the correct session.save_path. 2.Cookie problem: Make sure the cookie is set correctly. 3.Session expires: Adjust session.gc_maxlifetime value to extend session time.

How do you debug session-related issues in PHP?How do you debug session-related issues in PHP?Apr 25, 2025 am 12:12 AM

Methods to debug session problems in PHP include: 1. Check whether the session is started correctly; 2. Verify the delivery of the session ID; 3. Check the storage and reading of session data; 4. Check the server configuration. By outputting session ID and data, viewing session file content, etc., you can effectively diagnose and solve session-related problems.

What happens if session_start() is called multiple times?What happens if session_start() is called multiple times?Apr 25, 2025 am 12:06 AM

Multiple calls to session_start() will result in warning messages and possible data overwrites. 1) PHP will issue a warning, prompting that the session has been started. 2) It may cause unexpected overwriting of session data. 3) Use session_status() to check the session status to avoid repeated calls.

How do you configure the session lifetime in PHP?How do you configure the session lifetime in PHP?Apr 25, 2025 am 12:05 AM

Configuring the session lifecycle in PHP can be achieved by setting session.gc_maxlifetime and session.cookie_lifetime. 1) session.gc_maxlifetime controls the survival time of server-side session data, 2) session.cookie_lifetime controls the life cycle of client cookies. When set to 0, the cookie expires when the browser is closed.

What are the advantages of using a database to store sessions?What are the advantages of using a database to store sessions?Apr 24, 2025 am 12:16 AM

The main advantages of using database storage sessions include persistence, scalability, and security. 1. Persistence: Even if the server restarts, the session data can remain unchanged. 2. Scalability: Applicable to distributed systems, ensuring that session data is synchronized between multiple servers. 3. Security: The database provides encrypted storage to protect sensitive information.

How do you implement custom session handling in PHP?How do you implement custom session handling in PHP?Apr 24, 2025 am 12:16 AM

Implementing custom session processing in PHP can be done by implementing the SessionHandlerInterface interface. The specific steps include: 1) Creating a class that implements SessionHandlerInterface, such as CustomSessionHandler; 2) Rewriting methods in the interface (such as open, close, read, write, destroy, gc) to define the life cycle and storage method of session data; 3) Register a custom session processor in a PHP script and start the session. This allows data to be stored in media such as MySQL and Redis to improve performance, security and scalability.

What is a session ID?What is a session ID?Apr 24, 2025 am 12:13 AM

SessionID is a mechanism used in web applications to track user session status. 1. It is a randomly generated string used to maintain user's identity information during multiple interactions between the user and the server. 2. The server generates and sends it to the client through cookies or URL parameters to help identify and associate these requests in multiple requests of the user. 3. Generation usually uses random algorithms to ensure uniqueness and unpredictability. 4. In actual development, in-memory databases such as Redis can be used to store session data to improve performance and security.

How do you handle sessions in a stateless environment (e.g., API)?How do you handle sessions in a stateless environment (e.g., API)?Apr 24, 2025 am 12:12 AM

Managing sessions in stateless environments such as APIs can be achieved by using JWT or cookies. 1. JWT is suitable for statelessness and scalability, but it is large in size when it comes to big data. 2.Cookies are more traditional and easy to implement, but they need to be configured with caution to ensure security.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools