Home Backend Development PHP Tutorial PHP optimization---opcache configuration instructions

PHP optimization---opcache configuration instructions

Jul 29, 2016 am 08:56 AM
opcache php zend

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

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

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 Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1269
29
C# Tutorial
1249
24
PHP and Python: Comparing Two Popular Programming Languages PHP and Python: Comparing Two Popular Programming Languages Apr 14, 2025 am 12:13 AM

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP in Action: Real-World Examples and Applications PHP in Action: Real-World Examples and Applications Apr 14, 2025 am 12:19 AM

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

The Enduring Relevance of PHP: Is It Still Alive? The Enduring Relevance of PHP: Is It Still Alive? Apr 14, 2025 am 12:12 AM

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP vs. Python: Understanding the Differences PHP vs. Python: Understanding the Differences Apr 11, 2025 am 12:15 AM

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP and Python: Code Examples and Comparison PHP and Python: Code Examples and Comparison Apr 15, 2025 am 12:07 AM

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

PHP vs. Other Languages: A Comparison PHP vs. Other Languages: A Comparison Apr 13, 2025 am 12:19 AM

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

PHP and Python: Different Paradigms Explained PHP and Python: Different Paradigms Explained Apr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

See all articles