Professional LAMP: Linux®, Apache, MySQL®, and PHP5 Web Development
by Jason Gerner, Elizabeth Naramore, Morgan L. Owens, Matt Warden
12.1. Alternative PHP Cache
Alternative PHP Cache, or APC, is a PHP opcode caching engine, now provided for free as part of the PECL/PEAR repository. APC originated with Daniel Cowgill and George Schlossnagle, and was released by Community Connect, Inc. After the release of PHP5, Yahoo! modified APC to support the new Zend Engine, and it has since become part of PECL.
APC works by taking the compiled code from the PHP runtime engine and storing it in shared memory for later access. Each time a script is downloaded, APC checks for a version in shared memory first, before recompiling and executing the script that resides on disk. Because PHP doesn't need to recompile the script each time, it can greatly speed up the response time—speed increases of over four times or greater can be obtained in some situations.
APC can be installed as either a dynamic shared object (DSO), or built into PHP statically. The following section shows you how to install the DSO version, as it doesn't require you to recompile PHP, and provides the flexibility to add or remove the DSO at will.
12.1.1. Installing APC
First, grab a copy of the latest version of the APC source code from the PECL website: http://pecl.php.net/package/APC.
Once you have a copy of the source code in tar/gzip format, extract the package and change directory into the newly created source folder:
tar -xvzf APC-3.0.5.tgz cd APC-3.0.5
Next, run phpize in the source folder. Be sure to use the correct path to your installed copy of ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access