Alternative PHP Cache

From Phpmaniac

Jump to: navigation, search

Return to Contents

Contents

What is APC

APC is the Alternative PHP Cache and what it does is cache the resulting bytecode/opcodes of a PHP script which results in decreased loading times on subsequent requests.

Why use APC

APC increases the performance of you PHP applications significantly as no parsing or compiling is required on each page load.

Installation

Installation can be done either through your operating systems package manager, or through PECL (PHP Extension Community Library).

Pecl Install

Compile and install the binary in one step using the following command.

pecl install apc

Add the following line to your php.ini

extension=apc.so

Linux

Red Hat

Install httpd-devel using Yum

yum installl httpd-devel

Use the PECL install detailed above selecting yes when asked if you want to use the Apache shared module (apxs)

Create a file called /etc/php.d/apc.ini

; Enable apc extension module
extension=apc.so

Restart Apache

/etc/init.d/httpd restart

Other Linux

Use the PECL install detailed above

Windows

Download the windows binary http://pecl4win.php.net/ext.php/php_apc.dll for you version of PHP and place it in your extensions directory,

Add the following line to your php.ini

extension=php_apc.dll

FreeBSD

Using packages

Install the binary in one step using the following command.

# pkg_add -r pecl-APC

Add the following line to your php.ini (usually /usr/local/etc/php.ini)

extension=apc.so

Using Ports

Compile and install the binary in one step using the following commands.

cd /usr/ports/www/pecl-APC
make install clean

Usage

Once you have installed APC generally no further configuration is required. Your scripts will now use APC by default.

Return to Contents

Personal tools