Below method i tested with Ubuntu 10.04 and 12.04, they are all work well, hope it work well for all of other Ubuntu versions.
APC (alternative page cache) is an addon to php to increase execution time of PHP scripts. To do so APC caches previously compiled bytecode of PHP code which can be reused in later page requests. The install on Debian/Ubuntu based Linux distributions (in my case Ubuntu 12.04) is quite simple.
sudo apt-get install php-apc sudo service apache2 restart
Update: (Thorleif Wiik)
Use
sudo service php5-fpm restart
if you don’t use mod_php but php5-fpm with apache.
After install you should download the apc.php from the pecl repository The following line will download apc.php from version 3.1.10:
wget -O apc.php http://svn.php.net/viewvc/pecl/apc/trunk/apc.php?revision=325483&view=co
Upload this file to your webserver root. By calling the script you get a statistical representation of your memory used for APC. If your running a website which consumes a lot of memory, APC will unluckily fragment your memory cache a lot. Also the value Cache full count will increase. In that case you should increase the memory limit until it fits your needs by adding the following line to the apc configuration fileapc.ini which can be found in /etc/php5/conf.d:
apc.shm_size=64
Thats it! And the final step is configure it work well on Magento because the default configuration doesn’t work well. Let ‘s visit How to configuring APC cache for Magento?
Or take a look the slideshow below for more detail: