Alternative PHP Cache (APC)
APC is an Open Source PHP accelerator for caching intermediate code from scripts. Intermediate code is the internal memory structures produced during compilation that are fed into the executor. APC increases the performance of PHP scripts by caching them in their compiled state, so that the overhead of compiling is almost completely eliminated. APC stores and executes compiled PHP scripts from shared memory.
These commands are interpreted as follows:
1. Choose the directory under which you want to unpack the distribution, and then change location into it. In the following example, we unpack the distribution under /usr/local/src.
shell> cd /usr/local/src
2. Obtain an APC distribution from http://pecl.php.net/package/APC.
3. Unpack the source file, which creates the installation directory.
shell> tar -zxvf APC-x.x.x.tgz
4. Change location into the installation directory:
shell> cd APC-x.x.x
5. Run phpize. phpize is a script that is included with the PHP distribution, and is by default located in /usr/local/php/bin (assuming you installed PHP in /usr/local/php).
shell> /usr/local/php/bin/phpize (This path is the location of php)
The output from running phpize should look like the following:
PHP Api Version: 20020918
Zend Module Api No: 20020429
Zend Extension Api No: 20050606
6. Run the configuration script with the following parameters:
shell> ./configure –enable-apc –enable-apc-mmap –with-apxs=<location of apxs> –with-php-config=<location of php-config>
The –enable-apc-mmap option tells the APC configuration script to use mmap instead of the default IPC shared memory support.
The configure script will take several minutes to run, as it tests for the availability of packages and prerequisites on your system and builds the Makefiles that will later be used to compile APC.
7. Now you can build the APC components by running the command:
shell > make
8. Next, install the package by running:
shell> make install
10. Next you must edit your php.ini file, which is normally located in
/usr/local/php/lib/php.ini, and add the following line:
11.Replace “/path/to/php/extensions” with whatever path was displayed when you
ran make install above.
Then restart your web server and consult the output of phpinfo(). If there is
an informational section for APC, the installation was successful.
Article Authored by Junitha M
Author, Junitha, is a Systems Engineer with SupportPRO. Junitha specializes in Cpanel and Linux servers. SupportPRO offers 24X7 outsourced technical support to web hosting companies and service providers.