Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / programming / optimization

PHP accelerations: How to configure Alternative PHP Cache (APC) on Windows

5.00/5 (3 votes)
10 Jan 2013CPOL2 min read 26.5K  
APC is a very popular PHP extension to optimize PHP developments.

Introduction

According to the Wikipedia, accelerations of PHP means to cache the compiled bytecode of PHP scripts to avoid the overhead of parsing and compiling source code on each request. I have used Alternative PHP Cache (APC) to optimize my PHP developments as APC is a fully free and open source (PHP license) framework used for optimizing PHP codes and caches data and compiled code from the PHP bytecode compiler in shared memory.

You may collect the full source of APC from http://pecl.php.net/package/APC.

Occasionally I have been questioned about the procedure to configure APC on Windows platform and the purpose of this submission is how to configure APC on Windows step-by-step avoiding the problems generally found.

Environment  

I have used following versions here to test the complete configuration,

  1. APV 3.1.14 beta 
  2. WAMP server 2.2 containing PHP 5.3.13, Apache 2.2.22 and MySQL 5.5.24
  3. Windows 7 (64-bit) 

Configuration Steps

  1. At first, I have setup my WAMP Server on a location as E:\wamp. 
  2. Now to install APC, I have to copy php_apc.dll to the ext directory. On my system, the location is E:\wamp\bin\php\php5.3.13\ext\

    It's important to excerpt here that you will get the binaries of all versions of APC from the location as
    http://dev.freshsite.p/php-accelerators/apc.html

    As well as, you’ll collect the proper documentation on APC from
    http://www.php.net/manual/en/book.apc.php 
  3. Now open the initialization (php.ini) file from the location as E:\wamp\bin\php\php5.3.13\php.ini or you may follow the way depicted in following figure.
    Image 1

    Now just append following two lines at the very bottom of this initialization file as following figure.
    apc.enabled = 1
    apc.stat = 1

    Image 2
  4. Save the file php.ini and close it.
  5. Now restart the WAMP web server.
  6. Now copy the file apc.php from the archive APC-3.1.14.tgz after extraction, collected from the location http://pecl.php.net/package/APC and paste it to the folder accessible from web server. In my example it is E:\wamp\www\ 
  7. Now open your preferred browser and write on address bar as http://localhost/apc.php and enjoy the environment to improve the performance of your applications developed in PHP.

Conclusion  

As APC is a very popular PHP extension to accelerate PHP development, so you must capable to develop a very large scale of PHP development using it in Windows platform comparing same of Linux/Unix environment.

History

Initial post: 10th January, 2013.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)