jump to navigation

How to Install Alternative PHP Cache (APC) on Windows (WAMP) March 13, 2013

Posted by Tournas Dimitrios in PHP.

Alternative PHP Cache is a free open source extension for the PHP-engine (interpreter) . Its task is to store compiled results (bytecode) into shared memory (caching and optimizing PHP intermediate code) . If that sounds to cryptic , the following description is from the PHP-manual : “PHP is a script processing engine , which reads an input stream of data that contains text and/or PHP instructions and produces another stream of data , most commonly in the HTML format . This means that on a web server the PHP engine reads , parses , compiles and executes a PHP script each time that it is requested by a Web client . The reading , parsing and compilation operations puts additional load on the web server’s CPU and file system and thus affect the overall performance of a PHP web application . The PHP bytecode (opcode) cache is used to store the compiled script bytecode in shared memory so that it can be re-used by PHP engine for subsequent executions of the same script ”  .

For “heavy” applications consisting of a large source code base such as CMS Frameworks (WordPress , Drupal , Joomla , Zend , Symfony ) you can expect around a 3x increase in page generation speed as a result .There have been discussions about officially endorsement of  APC as a core feature in coming releases , it is scheduled for inclusion in the PHP core no later than PHP6 .

This article is just a quick “how-to install APC on WAMP ” for those developers that have chosen to develop their code on a Windows Os machine . A future article will go in more “depth” about the configurations that might affect (boost) the performance of this extension .  A bit of introspection has to be done before we can download the proper extension for our machine . First open a “phpinfo()”  file in you browser and note the following configurations (Ctrl + F on your browser) :

  • Loaded Configuration File”  : The location of PHP’s primary loaded configuration file
  • extension_dir”  : Where PHP expect to find all loaded extensions . On the Windows Platform , extensions have the “.dll” suffix .
  • Compiler”  : With what compiler Apache –the web-server —  was produced (on my machine its MSVC9 (Visual C++ 2008) ) . This information is crucial , as it defines which extension is compatible with the installed Apache .
  • Thread Safety”  : Most likely all Windows applications are “thread safe” , but to be sure , do a confirmation .

Pier’s website has a long list of pre-compiled extensions for the Windows Os . Each extension has the following signature “name–DateOfCreation–ReleaseNumber–ThreadMode–CompilerVersion–Platform.zip” . For instance , the following extension “php_apc-3.1.10-5.3-vc9-x86.zip” designates the following features .  It was compiled with a MSVC9 Compiler at 3 January 2010 , has release number 5.3 and is for a 32-bit platform (x86)  .  Notice : this extension has no “Thread_mode” designation in its name , so we make the assumption that this is a bundle of both “.dll’s” (ts and nts)  .  Other extensions may have the following name-convention php_xdebug-2.0.5-5.3-nts-Win32-VC9-x86.zip  , the “nts” designates a Non-Thread-Safe  extension .  Chose (and download) the extension that matches your machine’s  features . Unzip the downloaded extension into your PHP’s “extension_dir”  .  Caution : Some extensions have two folders in the downloaded zip-file (“nts” and “ts“) , chose the “.dll” that suits your machine (most likely “ts” — ie  : “Thread-Safe“– )  .  Now open PHP’s configuration file (php.ini) into your favorite text-editor and append the following directives into it :

apc.enabled = 1
apc.shm_segments = 1
apc.shm_size = 64M
apc.max_file_size = 10M
apc.stat = 1

Final important step , restart your web-server and open “phpinfo()” into a browser to verify that the APC-extension is enabled .


On an old machine (a Windows box) which is used by me to do all kind of tests , no extension downloaded from Pier’s website was compatible with my installation . Finally , I found this website , it has a compiled version that was compatible for my Wamp . That’s it … Of course there is a lot more , for instance , 30 configuration directives can further tweak APC’s functionality . For a development machine , the default configuration options should do the job . On production machines , a bit of tweaking is necessary to adapt APC to its maximum functionality .

A few links for further reading :


1. Homepage - March 20, 2013

… [Trackback]…

[…] Read More: tournasdimitrios1.wordpress.com/2013/03/13/how-to-install-alternative-php-cache-apc-on-windows-wamp/ […]…

2. WinUser - March 21, 2013

Very nice article, exactly what I was looking for.

3. Carlos - April 2, 2013

good post.

4. Tanmoy - May 12, 2013

Awesome…at last your tutorial did the trick, APC is running !!!!

tournasdimitrios1 - May 12, 2013

@to all
Thanks for “stopping by” , You are all very welcome .

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s