Friday, December 12, 2008

Integrating APC (Alternative PHP Cache) Into PHP5 (Fedora 8 & Apache2)

1 Preliminary Note

I have tested this on a Fedora 8 server where Apache2 and PHP5 are already installed and working. I'll use Apache's default document root /var/www/html in this tutorial for demonstration purposes. Of course, you can use any other vhost as well, but you might have to adjust the path to the info.php file that I'm using in this tutorial.

2 Checking PHP5's Current State

First, before we install APC, let's find out about our PHP5 installation. To do this, we create the file info.php in our document root /var/www/html:
  1. vi /var/www/html/info.php
  2. check phpinfo

3 Installing APC

  1. yum install php-pear
  2. yum install php-devel httpd-devel
  3. yum groupinstall 'Development Tools'
  4. yum groupinstall 'Development Libraries'
Now that all dependencies are installed, we can install APC as follows:
  • pecl install apc

Now that APC is installed, we create the configuration file /etc/php.d/apc.ini. We must at least add the line in there; all other configuration options are optional. You can find a list of all available configuration options on
  1. vi /etc/php.d/apc.ini
That's it. Restart Apache, and you're done:
  • /etc/init.d/httpd restart

No comments:

Post a Comment