Installing Alternative PHP Cache(APC) From Source Code

Anthony Zhan| 2013-08-06 Web Hosting, Server Management, Tutorials Comments( 0 )

"The Alternative PHP Cache (APC) is a free and open opcode cache for PHP. Its goal is to provide a free, open, and robust framework for caching and optimizing PHP intermediate code." From:

APC is quickly becoming the stand PHP caching mechanism as it will be included built-in to the core of PHP starting with PHP 5.4.

As a PECL extension, the easiest way to install APC is using the following commands, of cause you need PEAR(php5-pear) package installed on your system.

pecl install apc

But here I'm going to show you how to install APC from source code.

1.Get latest source code

tar zxf APC-3.1.9.tgz
cd APC-3.1.9

2. Run phpize.

phpize is a script that may have been installed with PHP, and is normally located in /usr/local/php/bin assuming you installed PHP in /usr/local/php. If you are running Debian system as I'm, you need install php5-dev package and will install it in /usr/bin/phpize. Run the phpize command under APC source code directory:


3. Run the configure script.

The only option you need to specify is the location of your php-config script(Maybe you can use "whereis php-config" command to find where is it):

./configure --with-php-config=/usr/bin/php-config

4. Compile and install the files(you may need to be root in order to install)

make install

In debian system I got a error message like this:

/usr/include/php5/ext/pcre/php_pcre.h:29:18: error: pcre.h: No such file or directory

To fix this error by installing package "libpcre3-dev"

apt-get install libpcre3-dev

5. Edit your php configure files

Copy the following line to the php configure file


6. Restart the web server and test the installation

Tagged with:

We hope webmasters to share and promote the good articles ,Please click herecontribute

You need to log in to commentLogin|Register

Be the first to comment!