Integrating APC (Alternative PHP Cache) Into PHP5 And Lighttpd (Fedora 9)

Want to support HowtoForge? Become a subscriber!
 
Submitted by falko (Contact Author) (Forums) on Thu, 2008-10-02 11:38. :: Fedora | Lighttpd | PHP

Integrating APC (Alternative PHP Cache) Into PHP5 And Lighttpd (Fedora 9)

Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Last edited 09/01/2008

This guide explains how to integrate APC (Alternative PHP Cache) into PHP5 and lighttpd on a Fedora 9 system. 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.

I do not issue any guarantee that this will work for you!

 

1 Preliminary Note

I have tested this on a Fedora 9 server with the IP address 192.168.0.100 where lighttpd and PHP5 are already installed and working. I'll use lighttpd's default document root /var/www/lighttpd 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/lighttpd:

vi /var/www/lighttpd/info.php

<?php
phpinfo();
?>

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

As you see, we have PHP 5.2.6 installed...

... but APC isn't mentioned anywhere on the page:

 

3 Installing APC

Fortunately, there's an APC package for Fedora 9, php-pecl-apc, which we can install like this:

yum install php-pecl-apc

The APC configuration is stored in the file /etc/php.d/apc.ini. You can read up on the various configuration settings on this page: http://de2.php.net/manual/en/apc.configuration.php.

Afterwards, we restart lighttpd so that our new PHP configuration takes effect:

/etc/init.d/lighttpd restart

Afterwards, open info.php again in a browser: http://192.168.0.100/info.php

You should now see APC mentioned on the page which means it has successfully been integrated and is working as expected:

 

4 Links


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Anonymous (not registered) on Sat, 2011-05-07 21:43.

The part of this page that helped me is

The APC configuration is stored in the file /etc/php.d/apc.ini.

Submitted by AnilKumar (registered user) on Fri, 2009-03-06 10:10.
Hi, this is very useful site for our php.

http://anil2u.wordpress.com
http://phpforum.freeforums.org/
http://anil4php.ning.com/