Compile and install Zend Opcache cache opcache, accelerating PHP

Source: Internet
Author: User
Tags apc zend
<span id="Label3"></p><p><p>Optimizer+ is the first and fastest opcode caching tool for Zend developed closed-source, but Free-to-use PHP optimization acceleration components. now, Zend technology company will optimizer+ under PHP License open source becomes Zend Opcache.</p></p><p><p><span style="color: #ff0000;"><strong>GitHub address</strong></span> : Https://github.com/zendtech/ZendOptimizerPlus</p></p><p><p>The Zend Opcache provides faster PHP execution through opcode caching and Optimization. It stores precompiled script files in shared memory for later use, avoiding the time consuming of reading code from disk and compiling it. It also applies some code optimization patterns to make code execution faster.</p></p><p><p></p></p><p><p><strong>first, what is the opcode cache?</strong></p></p><p><p>When the interpreter finishes parsing the script code, it generates intermediate code that can be run directly, also known as the opcode (Operate code,opcode). The goal of the Opcode cache is to avoid duplication of compilation and reduce CPU and memory Overhead. If the performance bottleneck for dynamic content is not CPU and memory, but I/O operations, such as disk I/O overhead from database queries, the performance gains of the opcode cache are very limited. But since the opcode cache can lead to a reduction in CPU and memory overhead, This is always a good thing--in an environmentally friendly manner, you should also minimize Consumption. :D</p></p><p><p>Modern opcode buffers (optimizer+,apc2.0+, others) are stored using shared memory and can be executed directly from the file without the "deserialization" code before Execution. This leads to significant performance acceleration, which typically reduces the overall server's memory consumption and has few drawbacks.</p></p><p><p></p></p><p><p><strong>Comparison of advantages and disadvantages between optimizer+ and APC</strong></p></p><p><p>Optimizer+ was renamed Opcache in Mid-March 2013.</p></p><p><p>Based on the discussion on the PHP wiki, Zend Opcache is about to be integrated into PHP 5.5. As an APC competitor, the new Zend Opcache is likely to replace the APC location, although Optimizerplus does not have the user cache function like Apc.</p></p><p><p><strong>optimizer+ Advantages Relative to APC</strong></p></p><p><p>1, Performance. According to the test, Zend optimizer+ is always superior to APC. With code differences, the number of requests processed per second is 5~20% High. Google Doc recorded on the test results, WordPress 2.1.1 (do not know why not a new version of WP to test), performance improvement of about 8%. theoretically, for WP 3.5.1, performance should also be able to get about 5~10% upgrade it. For servers running WordPress, using optimizer+ can significantly reduce CPU usage and increase page load speed (graphics here).</p></p><p><p>2, support the new PHP Version. Zend and the PHP community will help optimizer+ to support the latest version of PHP.</p></p><p><p>3, Reliability. The optimizer+ has an optional corruption detection capability to prevent server crashes due to data corruption.</p></p><p><p>4, Better Compatibility. PHP community intends to make optimizer+ compatible with all PHP versions supported by the community</p></p><p><p><strong>Advantages of APC Relative optimizer+</strong></p></p><p><p>1, APC has data caching API, and optimizer+ Not.</p></p><p><p>2. APC is able to reclaim the memory occupied by the old invalid Script. APC has a memory manager that can reclaim memory associated with scripts that are no longer in Use. Unlike optimizer+, it marks such memory as "dirty", but does not reclaim Them. Once the percentage of "dirty" memory footprint configuration thresholds reaches a certain value, optimizer+ will restart Itself. This behavior has both advantages and disadvantages in Stability.</p></p><p><p></p></p><p><p><strong>third, Compile and install Zend Opcache</strong></p></p><p><p>It is now possible to use Zend Opcache instead of APC as the PHP optimizer acceleration Tool. The current Zend Opcode is compatible with PHP 5.2.*, 5.3.*, 5.4.*, and PHP-5.5 development editions. however, support for PHP 5.2 will be canceled in the Future.</p></p><p><p><strong><span style="color: #ff0000;">note:</span></strong> Zend Opcache conflict with Eaccelerator. To install Zend opcache, you may need to uninstall Eaccelerator--first if you use this accelerator module.</p></p><p><p>Compile and install Zend Opcache</p></p><p><p>#下载源代码 (<span style="color: #0000ff;">wget-c</span> code Address)</p></p><p><p>Https://github.com/zendtech/ZendOptimizerPlus/archive/master.zip</p></p><p><p>#切换解压后的源码目录, perform the installation with Phpize</p></p><pre class="brush:bash;"><pre class="brush:bash;">cd/usr/local/src/zendoptimizerplus-master/usr/local/php/bin/phpize./configure--with-php-config=/usr/local/php/ Bin/php-configmake && make Install</pre></pre><p><p>#编辑<span style="color: #0000ff;">php.ini</span>, add the Following:</p></p><pre class="brush:bash;"><pre class="brush:bash;">zend_extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/opcache.soopcache.enable= 1opcache.memory_consumption=128opcache.interned_strings_buffer=8opcache.max_accelerated_files= 4000opcache.revalidate_freq=60opcache.fast_shutdown=1opcache.enable_cli=1</pre></pre><p><p>#重启php-fpm</p></p><pre class="brush:bash;"><pre class="brush:bash;">Service PHP-FPM Restart</pre></pre><p><p><strong>Opcache related parameters, can refer to:</strong></p></p><p><p><strong><span style="color: #0000ff;">GitHub</span></strong>: Https://github.com/zendtech/ZendOptimizerPlus</p></p><p><p>In the GitHub page above, there is a recommended configuration:</p></p> <blockquote> <blockquote> <p>We recommend the following configuration options for best performance<br>In a production Environment.</p> <p>Opcache.enable=1<br>opcache.memory_consumption=128<br>Opcache.interned_strings_buffer=8<br>opcache.max_accelerated_files=4000<br>Opcache.revalidate_freq=60<br>Opcache.fast_shutdown=1<br>Opcache.enable_cli=1</p> </blockquote> </blockquote><p><p><span style="color: #0000ff;"><strong>PHP manual</strong></span> : http://php.net/manual/zh/opcache.configuration.php</p></p><p><p></p></p><p><p><strong>Iv. viewing Zend Opcache running status</strong></p></p><p><p>by <span style="color: #0000ff;">phpinfo ();</span> function, You can see the Opcache running State:</p></p><p><p></p></p><p><p><strong>note:</strong> The unit of used memory and free memory is <strong><span style="color: #ff0000;">bytes</span></strong> .</p></p><p><p></p></p><p><p>Compile and install Zend Opcache cache opcache, accelerating PHP</p></p></span>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.