HOWTO: Install PECL APC Cache with XAMPP on Linux

XAMPP is a packaged, self-contained distribution of Apache, Mysql, PHP and tons of hard-to-install PHP extensions. Not only does it make sysadmin's life easier, by solving 99.9% of LAMP problems out-of-the-box, but it also allows PHP-vendors to create packaged distributions of complex systems. Even with a long list of packaged extensions that XAMPP ships with, it still does not contain everything.

Irakli Nadareishvili
#Development | Posted

XAMPP is a packaged, self-contained distribution of Apache, Mysql, PHP and tons of hard-to-install PHP extensions. Not only does it make sysadmin's life easier, by solving 99.9% of LAMP problems out-of-the-box, but it also allows PHP-vendors to create packaged distributions of complex systems. Even with a long list of packaged extensions that XAMPP ships with, it still does not contain everything. One crucial missing PECL plug-in is the Alternative PHP Cache (APC). APC is a rock-solid op-cache for PHP script pre-compilation and caching. It is used in massive deployments like Yahoo!. XAMPP comes packaged with eAccelerator, another popular PHP op-cache. Both eAccelerator and APC used to suffer from the infamous Segmentation Fault bug that freezes Apache randomly. Due to this bug, one could only use the benefits of the op-caches in redundant deployments. Fortunately, the bug was fixed in the latest release of APC, making APC even more appealing than before. Following is a 5-minute run-through of APC installation on XAMPP/Linux:

  1. Make sure you uninstall or disable all and any PHP installations you may have had before. Same goes for legacy PECL and PEAR installations.
  2. Download and install the latest XAMPP distribution.
  3. (Optionally) Add /opt/lampp/bin to your PATH
  4. Download and install XAMPP Development Package.
    Caution: this step will overwrite any configuration changes you might had made to XAMPP, previously.
  5. Download APC version 3.0.16 or later.
  6. $ sudo su - (or change to root in any other way you can)
  7. # cd APC-3.0.16
  8. # /opt/lampp/bin/phpize
  9. # ./configure
  10. # make (ignore the request to run "make test")
  11. # make install
  12. Edit /opt/lampp/etc/php.ini and add the following lines:  extension="apc.so" apc.enabled="1" apc.shm_size="30"
  13. Restart Apache by issuing: /opt/lampp/lampp restart
  14. Make sure APC got installed by issuing: "/opt/lampp/bin/php -m" and looking at the list of installed PHP extensions.

* * *

Irakli Nadareishvili