Assemble APC (alternative PHP Cache) to improve PHP parsing speed

Source: Internet
Author: User
Tags apc
Install APC (alternative PHP Cache) to improve PHP parsing speed

This article refers to "high-performance PHP development" to make the next record

PHP must perform the 5 steps required, whether from the command line or from a WEB server.


The Zend engine must read the file from the file system, scan its dictionaries and expressions, parse the file, create the computer code to be executed (called Opcode), and finally execute the Opcode.

PHP has a very short life cycle, but it must perform these 5 steps each time a request is initiated against the script. Each time a request arrives for a specific PHP script, the Zend engine must recreate the Opcode of the file, even if there is no change to the contents of the PHP script. The initial request for the script is necessary, but subsequent requests do not need to do so. If you implement the Opcode cache, you can omit three steps to shorten the life cycle of PHP

1) dictionary parsing;

2) analysis;

3) Create Opcode


APC can implement a Opcode cache of PHP scripts, but the APC cannot be turned on during development, or the script is modified, or the Zend engine executes the Opcode in the cache.

PECL APC Address: HTTP://PECL.PHP.NET/PACKAGE/APC

Install APC, take CentOS6.5 64-bit as an example

wget http://pecl.php.net/get/APC-3.1.9.tgz #下载tar zxvf apc-3.1.9.tgz  #解压cd APC-3.1.9   #切换目录phpize   #调出 Configure configuration file./configure--with-php-config=/usr/local/php/bin/php-config  #配置make && make install #编译安装

Build apc.so after success

Open php.ini Add

Extension=apc.soapc.enabled=1apc.shm_segments=1apc.shm_size=128apc.stat=0apc.ttl=0

Save, restart Apache/nginx.

Attach APC Common settings parameters, everyone live to see it ~


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