Popular Posts
Tools and Tips
Search
Archives
Wednesday, January 9. 2008
How to install APC in Ubuntu 7.10
APC, or Alternative PHP Cache, is a framework for PHP to cache opcodes. Opcodes are the actual instructions that are used when PHP executes scripts. By caching these, you can usually vastly improve performance across the board for PHP based applications. This guide covers installing APC in Ubuntu 7.10 with PHP5 and Apache2.Setting up
This guide assumes you already have Apache2 and PHP5 working, and I personally like to use Xdebug to profile and verify improvements I make.
First we're going to open up a terminal (Applications->Accessories->Terminal). If you haven't installed PEAR and php5-dev, you'll have to grab those packages as well.
sudo apt-get install apache2-threaded-dev
Again, if you need to install pear and php5-dev, you can use this instead
sudo apt-get install apache2-threaded-dev php5-dev php-pear
Installing APC
Once that is done installing, we can use pecl and install APC. Before I install APC, I'm going to use Xdebug to benchmark my current setup to see how much of an improvement I can get.
sudo pecl install apc

That will get APC through pecl, and build it. Once it's finished, we can open up our php.ini file
sudo gedit /etc/php5/apache2/php.ini
And add in the extension...
extension=apc.so
Save your php.ini file, and we're good to go. All we have to do now is restart apache, by using
sudo /etc/init.d/apache2 restart
Testing
And by checking the output of phpinfo() in a PHP script, we can make sure that it's installed correctly and running.

Now I'll reload my setup again. Without even looking at the benchmarks, I can tell that the load time has improved, especially on the second load, almost instantly. The benchmarks will hopefully confirm my assumption.
Results

With APC installed and enabled, we have cut the time cost in half, and the page loads noticably faster. The numbers say it's about a ~50% improvement in speed. All in all, well worth the time to install.
If you want to learn more about APC, you can check it out on pecl and php.net.
Share
Save This Page
Stumble It!Digg it
Trackbacks
Trackback specific URI for this entry
No Trackbacks
