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

How to integrate APC (Alternative PHP Cache) into PHP5 on a Fedora 13 system (with Apache2). APC is a free and open PHP opcode cacher for caching and optimizing PHP intermediate code. It’s similar to other PHP opcode cachers, such as eAccelerator and XCache.

1 Preliminary Note

tested this on a Fedora 13 server with the IP address 192.168.0.100 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

2 Checking PHP5’s Current State

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:

vi /var/www/html/info.php

call that file in a browser: http://192.168.0.100/info.php

see that another PHP opcode cacher such as eAccelerator is installed, you must remove it before you install APC

yum remove php-eaccelerator

Restart Apache

/etc/init.d/httpd restart

3 Installing APC

APC is a PHP extension that can be installed

[ccINb_bash width="700"]
yum install php-pecl-apc

APC is installed, take a look at the configuration file /etc/php.d/apc.ini. The default settings should be ok, but in case you want to change anything, you can find a list of all available configuration options on http://de2.php.net/manual/en/apc.configuration.php

vi /etc/php.d/apc.ini

Restart Apache, and you’re done

/etc/init.d/httpd restart

Leave a comment