Installing Alternative PHP Cache (APC)

0

APC is the Alternative PHP Cache, which is a free, open, and robust framework for caching and optimizing PHP intermediate code. What this means is that APC reads your PHP files, parses them into a more efficient binary format and then caches them in memory so that each request for your PHP files and PHP library files can be fed from the parsed cache. This will generally lead to a speed increase when serving a PHP site, especially one with a lot of library files.

Alternative PHP Cache (APC) will be integrated by default on PHP6. Though this setting will default to off, APC’s caching can significantly increase the speed of your web application. There are currently some great PHP caching libraries available but integrated support can make the system run faster.

  1. To install it with the default CLI version of php, use the following:

wget http://pecl.php.net/get/APC-3.1.9.tgz
tar xvzf APC-3.1.9.tgz
cd APC-3.1.9
/usr/local/bin/phpize

Here an error may appear:

Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

you can fix it with: yum -y install autoconf

 

whereis php-config
./configure –with-php-config=/usr/local/bin/php-config
make
make install

2. Then, we needed to edit the php.ini to add the code:

extension=apc.so
apc.enabled=1
apc.shm_size=128M
apc.ttl=7200
apc.user_ttl=7200
apc.enable_cli=1

3. service httpd restart

When you download and install the APC cache, there’s a file in the root level of the source archive called apc.php – this is a PHP script which allows you to view information about the status of the PHP Cache as shown in the screenshots below. You simply need to copy the apc.php file to a directory that is served by your Apache (or other) web server and then load up the page in your browser.

 

Share.

About Author

Comments are closed.