[PHP]-performance acceleration-turn on Opcache

Source: Internet
Author: User
Tags apc zend

Description

PHP 5.5+ version above, you can use PHP's own opcache to turn on performance acceleration (the default is off). For PHP versions below 5.5, APC acceleration is required, which does not indicate that the PHP APC acceleration method can be searched on its own internet.

PHP Open Opcache method

1. Open php.ini File

2. Find: [Opcache], set to:

[Opcache]; DLL address Zend_extension=php_opcache.dll; Switch to open opcache.enable=1; Open Cliopcache.enable_cli=1; Available memory, as appropriate, in units: mbopcache.memory_consumption=528; Zend Optimizer + The total memory of the string in the staging pool. (unit: MB) opcache.interned_strings_buffer=8; For multi-cache file limit, hit less than 100%, you can try to improve the value of opcache.max_accelerated_files=10000; Opcache will be in a certain time to check the file modification time, here set check the time period, the default is 2, positioning for the second opcache.revalidate_freq=1; Turn on quick close to open this the memory recovery rate will increase when PHP Request shutdown opcache.fast_shutdown=1

3. Restart Apache.

Test

After the configuration is complete, you can query the Opcache using the following code:

<?php    phpinfo ();? >

Visit the page to get the following interface:

The following are the configuration instructions for Opcache:

[opcache]zend_extension = "G:/php/php-5.5.6-win32-vc11-x64/ext/php_opcache.dll"; Zend Optimizer + switch, code is no longer optimized when off. opcache.enable=1; Determines if Zend Opcache is enabled for the CLI version of Phpopcache.enable_cli=1; Zend Optimizer + Shared memory size, how many precompiled PHP code can be stored in total (MB); Recommended 128opcache.memory_consumption=64; Zend Optimizer + The total memory of the string in the staging pool. (unit: MB); Recommended 8opcache.interned_strings_buffer=4; Maximum number of cached files between 200 and 100000; Recommended 4000opcache.max_accelerated_files=2000; Memory "Wasted" reaches the percentage corresponding to this value, a restart schedule is initiated. opcache.max_wasted_percentage=5; Open this command, Zend Optimizer + will automatically append the name of the current working directory to the script key; This eliminates key-value naming conflicts between files of the same name. Closing this command will improve performance; However, it can cause damage to existing applications. Opcache.use_cwd=0; Open file timestamp verification Opcache.validate_timestamps=1; 2s Checking for file updates Note: 0 is always checked not off; Recommended 60opcache.revalidate_freq=2; Allow or prohibit the optimization of file search in include_path; opcache.revalidate_path=0; Whether to save comments on file/function if Apigen, Doctrine, ZF2, phpunit need file comment; Recommended 0opcache.save_comments=1; Whether to load the comments of the file/function; Opcache.load_comments=1; Turn on quick close, open this when PHP Request shutdown the memory will be increased; Recommended 1opcache.fast_shutdoWn=1 the optimization feature that allows overwriting of file presence (file_exists, etc.). ; opcache.enable_file_override=0; Define how many optimization processes to start; opcache.optimization_level=0xffffffff; Enabling this hack can temporarily resolve the "can ' t Redeclare class" error.; o pcache.inherited_hack=1; Enabling this hack can temporarily resolve the "can ' t Redeclare class" error.; o pcache.dups_fix=0; Set a blacklist that does not cache; PHP files beginning with cache_ in the specified directory are not cached. /png/www/example.com/public_html/cache/cache_; opcache.blacklist_filename=; The cache of large files is removed through the file size screen. By default, all files are cached.; o pcache.max_file_size=0; Check cache checksum once per N requests. The default value of 0 indicates that the check is disabled.; Due to the calculation of the checksum lossy performance, this directive should be tightly opened at the time of development debugging. O pcache.consistency_checks=0; When the cache is not accessed, the wait time (in seconds) for the scheduled restart; opcache.force_restart_timeout=180; The error log file name. Empty indicates the use of standard error output (stderr).; o pcache.error_log=; Write error message to server (Apache etc) log; opcache.log_verbosity_level=1; The preferred background for memory sharing. Leave blank to let the system choose.; o pcache.preferred_memory_model=; Prevent accidental writes during script execution within a share, for internal debugging only.; o Pcache.protect_memory=0

Article reference

Improve PHP 5.5+ program performance with Opcache

https://phphub.org/topics/301

PHP Opcache Configuration

Https://blog.hackroad.com/operations-engineer/windows_server/9311.html

[PHP]-performance acceleration-turn on Opcache

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.