PHP5.5 Zend Opcache Installation Configuration tutorial

Source: Internet
Author: User
Tags install php ini php script zend


Optimizer+ is the Zend developed closed source but can be used for free PHP optimization acceleration components, is the first and fastest opcode cache tool. Now, Zend technology company will optimizer+ under the PHP License Open source becomes Zend Opcache.

Zend Opcache provides faster PHP execution through opcode caching and optimization. It stores the precompiled script files in shared memory for later use, thereby avoiding
Disk reads the code and compiles the time consumption. It also applies some code optimization patterns that make code execution faster.


Official website: Http://pecl.php.net/package/ZendOpcache

Execute the following command sequentially

wget http://pecl.php.net/get/zendopcache-7.0.3.tgz
Tar xzf zendopcache-7.0.3.tgz
CD zendopcache-7.0.3
Phpize
# # #如果找不到phpize words to find their own PHP path, my/usr/local/php/bin/phpize, the following line will also be based on your php.ini path to modify
./configure--with-php-config=/usr/local/php/bin/php-config
Make
Make install

If the display installing shared extensions:/USR/LOCAL/PHP/LIB/PHP/EXTENSIONS/NO-DEBUG-ZTS-20100525/indicates that the installation is complete, The following is to modify the PHP configuration file for it to take effect

2. Enable Zend Opcache

Note: If you use the Windows Development environment, or if you install PHP with a command such as brew or apt-get, you can skip the compile step.
By default, Zend Opcache is not turned on, and we need to use--enable-opcache at compile time to specify enable Zend Opcache.

After compiling PHP, you also need to specify the Opcache extension path in php.ini:

Zend_extension=/path/to/opcache.so

In general, PHP will display a successful Zend Opcache extension path, but if not, you can use the following command to locate the PHP extension directory:

Php-config--extension-dir

Note: If you use Xdebug, you need to load the Zend Opcache in php.ini and then load the xdebug.
Restart the PHP process after updating the php.ini and see if the success is enabled:

Php-zendopcache

3, configure Zend Opcache

After you enable Zend Opcache, you also need to configure Zend Opcache in PHP.ini, and here is a sample configuration for reference:

Opcache.validate_timestamps=1//Production environment is configured to 0
Opcache.revalidate_freq=0//Check whether the script timestamp has an updated time
opcache.memory_consumption=64//opcache Shared memory size, in M
OPCACHE.INTERNED_STRINGS_BUFFER=16//memory size used to store temporary strings, measured in M
opcache.max_accelerated_files=4000//opcache Hash table can store the maximum number of script files
Opcache.fast_shutdown=1//Use Quick Stop renewal event
Note: Later we will further introduce the configuration of Zend Opcache, PHP official website listed Zend Opcache all settings: http://ua2.php.net/manual/zh/opcache.configuration.php.

4. Use Zend Opcache

Zend Opcache is easy to use because it automatically runs after it is enabled, and Zend Opcache automatically caches precompiled PHP bytecode in memory, and executes the byte code if the bytecode of a file is cached.

If the php.ini is configured with a opcache.validate_timestamps value of 0, be careful because Zend Opcache will not be aware of changes to the PHP script and must manually empty the Zend Opcache cached byte code. To allow it to find changes in PHP files. This configuration is designed to be set to 0 in a production environment, but it can be inconvenient in the development environment, which enables the automatic authentication caching feature to be configured in the development environment:

Opcache.validate_timestamps=1
Opcache.revalidate_freq=0

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.