Update:
On Ubuntu 12.04 LTS (Precise Pangolin) the repositories already contain a package called php-apc that works very well. There is no need to install APC using pecl at all as in the article below.
Complex PHP applications, such as Drupal, can gain a lot of performance benefits from running a PHP op-code cache/accelerators.
APC, Alternate PHP Cache, is now the most maintained free/open source op-code cache, and is being used more and more as it emerges to be the most stable.
The instructions here detail how to get APC running on an Ubuntu server running Gutsy Gibbon 7.10.
First, we need the pecl command so we can download and install APC from the repositories.
Do to so, we execute the following command:
aptitude install php-pear
But, this will not run on its own, we need the following package for the phpize command:
aptitude install php5-dev
We also need the apxs command, which is installed via the following package:
aptitude install apache2-dev
Now we have all the software we need, so we install apc via the pecl command:
pecl install apc
Once that finishes, we need to enable apc in Apache's configuration. the following command should do this for us.
echo "extension=apc.so" > /etc/php5/apache2/conf.d/apc.ini
Then we restart Apache:
/etc/init.d/apache2 restart
And we are all done. Watch for less execution time per page, and decreased memory usage per Apache process compared to what you had before.
Comments
Visitor (not verified)
Hi, thank you for the
Sun, 2009/06/21 - 08:55Hi, thank you for the tutorial. I was unable to complete the pecl command and encountered this error message:
however, this was resolved with
Thank you. This is on an installation of Debian 5.
Visitor (not verified)
On Ubuntu, I also had to
Tue, 2010/01/19 - 06:26On Ubuntu, I also had to install apache2-threaded-dev:
sudo apt-get install apache2-threaded-dev
Before running:
sudo pecl install apc
and then:
gksudo gedit /etc/php5/apache2/conf.d/apc.ini
...paste in the file:
extension=apc.so
and save it.
Visitor (not verified)
this worked :) and on the
Mon, 2009/07/06 - 14:53this worked :) and on the latest version of ubuntu...
Thanks!
Visitor (not verified)
apt-get
Sun, 2010/01/17 - 00:20I had problems getting this to work on PHP 5.2.12-0.dotdeb.1 This link explains the .dotdeb version does not override the default php-config to php-config5 necessary for phpize.
I tried this:
Running
pecl install apc --with-php-config=/usr/bin/php-config5
But it gave me this error:
:(
Finally I just ran this:
apt-get install php-apc
Everything seems fine!
Khalid
Depends on version and repository
Sun, 2010/01/17 - 10:09I always advocate using the long term support (LTS) server version (8.04 at present), and only the official repositories. This makes things easier and more contained. For 8.04 LTS, there is no pre-built APC package in the official repositories.
Ubuntu 9.10 has a php-apc package, but it is not a long term support version, and hence not suitable for live servers.
Visitor (not verified)
APC and ZendOptimizer
Mon, 2010/03/08 - 18:40Few months ago I have installed Zend Optimizer in my Drupal site.
To improve performance I have installed APC and my site is crashing.
Is there a problem with Zend Optimizer and APC? How can I uninstall APC?
Most of my users are unregistered. Would I use Zend or APC?
Khalid
Removing APC
Mon, 2010/03/08 - 19:08Did you install APC using pecl? If so then issue this from the command line:
pecl uninstall APC
Otherwise, just prevent APC from getting loaded. Find in your php.ini the place that has apc.so, and add a semicolon (;) before that line. That will have the same effect.
Visitor (not verified)
Good stuff, worked very
Fri, 2010/08/13 - 08:14Good stuff, worked very quickly for me and had my php running almost six times faster with a third of the memory allocation!
Visitor (not verified)
Installing PHP/APC on Ubuntu
Wed, 2011/06/15 - 11:32Hi there,
Noobie question here. Hope you can help me. I'm trying to install APC on Ubuntu server 8, and these have been the best instructions I've been able to find so far, so thanks!
I'm running into problems after downloading the pacakages. Specifically, when I try the pecl install apc command, I get the following:
54 source files, building
running phpize
Cannot find config.m4
Make sure that you run '/usr/bin/phpize' in the top level source directory of the module
ERROR: 'phpize' failed
I do have a config.m4 file in the /usr/local/src/APC-3.0.19 directory, which is where I'm trying to run pecl install apc
Now, if I run /usr/bin/phpize, I get a little bit farther:
/usr/local/src/APC-3.0.19# /usr/bin/phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
At that point I continued on with the remaining steps, no errors.
But I'm not sure if this worked. How do I verify the APC module is installed?
Thanks for any suggestions.
Sir_timbit