Skip to main content
Home
The Baheyeldin Dynasty
The journey for wisdom starts with knowledge
  • Home
  • About
  • Site Map
  • Contact

Installing PHP APC on Ubuntu Dapper (and Debian?)

  1. Home

By Khalid on 2006/06/14 - 20:43, last updated 2022/11/17 - 15:52

Update: this article is for Ubuntu Dapper Drake (6.06). If you are using later versions, or other Linux distributions, then visit the following links:

  • Installing PHP APC on GNU/Linux Gusty Gibbon 7.10 and (Debian).
  • Installing PHP APC on GNU/Linux CentOS 5.

APC is a op-code cache for PHP that eliminates the parsing and compiling of script(s) for every page hit. Unlike Zend, it is truly free, and seems to have a lot of commuity momentum behind it lately.

As with all optimizations, there is a trade off. APC can use more memory on your server than without it.

The instructions below assumes that you have full control of your server, whether a physical dedicated server or a virtual private server.

Although one can always compile from source, this is more time consuming than using Debian's excellent apt-get.

Here is how I did it on two machines, with one more to go.

Getting the packages

First, we run apt-get to get what we need, if it is already not there.

apt-get update
apt-get install apache2-dev php5-dev php-pear make

Preparing for pecl

I am using Apache2 and PHP5 on the development server. Adjust the versions above if necessary to match your environment.

Since I am using Apache2, the apxs is named differently, and pecl will fail if I do not work around this. So, I had to provide an apxs which is just a symbolic link.

ln -s /usr/bin/apxs2 /usr/bin/apxs

Running pecl

Next we use pecl to download, compile and install APC.

pecl install apc

My development server is now an AMD Athlon 64, using a 64-bit kernel. It had a strange problem running the above pecl command, with an error saying:

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 143 bytes) in /usr/share/php/PEAR/PackageFile/v2.php on line 1772

The same Ubuntu version on my Pentium III test server does not have this error at all. It has the same Apache and PHP versions as well.

Others have encountered this problem, and the workaround as provided in this page, is to adjust the memory inside the script (it does not work in the php.ini).

Edit the /usr/share/php/pearcmd.php, and add:

@ini_set('memory_limit', '16M');

Configuration

Now you can run the above pecl command once more.

Now, all you need to do is to add the following to the /etc/php5/apache2/php.ini file:

extension=apc.so

Now, restart Apache using:

/etc/init.d/apache2 restart 

Now you have a code cache that should speed up Drupal, and you can benefit.

To upgrade APC in the future, use the commands:

pecl upgrade apc

Followed by:

 /etc/init.d/apache2 restart

More info

APC is not the only op-code cache / accelerator.

You can read more in PHP op-code caches / accelerators Drupal big site study.

There is also a benchmark of APC and eAccelerator using Drupal.

Links and Resources

  • PHP APC home page.
  • Matthew Carroll provided the outline for the procedure above.
  • Darrel O'Pry on Debian and APC provides an alternative method.
  • Benchmarks of various web servers with Drupal by Dries. APC makes a huge difference.
  • List of PHP op code caches.
Contents: 
Linux
Drupal
  • Add comment

Comments

Swaminathan (not verified)

Php-apc

Thu, 2007/12/06 - 05:43

Hi, Thank you very much...

The Php-apc is working fine...

thanks a lot

luv
Swami

  • reply

Don Piano (not verified)

"Fatal error: Allowed memory size of 8388608 ... " - fixed

Fri, 2008/02/01 - 17:35

Thank you! I was trying to find/fix the cause of the error "Fatal error: Allowed memory size of 8388608 bytes exhausted...", and the method you recommended of adding "@ini_set('memory_limit', '16M');" to the pearcmd.php file worked. For anyone interested, this is where I put it in the file:
.
.
.
@ini_set('track_errors', true);
@ini_set('html_errors', false);
@ini_set('magic_quotes_runtime', false);
@ini_set('memory_limit', '16M');//HACK to fix pecl install memory issue
.
.
.

  • reply

Srini (not verified)

APC installation errors

Sat, 2008/02/09 - 05:05

Hi,

Just wanted to paste the umpteen errors and their resolution during installation of APC. And you know what I still haven't see the end of the tunnel :(

I am installing this in Ubuntu and had configured PHP and apache using XAMPP.

Installing APC
1. Try the below command to install APC
sudo /opt/lampp/bin/pecl install apc
i. Got an error relating to Autoconf
" Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF
environment variable is set correctly and then rerun this script."

Resolved this by
sudo apt-get install autoconf

ii. This ask for something like "Use apxs" - give "yes" for this and then as 1-1, all, abort or Enter to continue. Enter here to continue.
2. Got an error here
"Configure: error: C compiler cannot create executables
See `config.log' for more details."
Resolved this using
sudo apt-get install g++

3. Got an error again

"Sorry, I was not able to successfully run APXS. Possible reasons:
1. Perl is not installed;
2. Apache was not compiled with DSO support (--enable-module=so);
3. 'apxs' is not in your path. Try to use --with-apxs=/path/to/apxs"
Resolved this using
sudo apt-get install apache2-threaded-dev

4. Got another error
error apc.h:61:17 php.h No such file or directory

Still looking for a solution to this :(!!

  • reply

George Popov (not verified)

APXS error

Thu, 2008/06/26 - 04:48

To all the people who get the apxs error - Is there any chance your writing "y" instead of "yes" (or just hitting enter) when you get prompted whether or not to compile with apxs?

  • reply

joel (not verified)

Thanks

Mon, 2008/09/08 - 03:19

Thanks for this wonderfull post. It really helped me!!!!! :)

  • reply

Norio (not verified)

Great article

Tue, 2008/12/09 - 01:08

Great article, thanks :)  I've just installed APC now and it's working beautifully!

  • reply

GalaxyBoss (not verified)

Usefull

Sat, 2010/01/09 - 05:08

thank it was useful informaton

test and work in ubuntu 9.10

  • reply

Mark Rairdon (not verified)

pecl command fails

Sun, 2010/06/20 - 00:25

with this error on Ubuntu 10.04 Lucid Linx (64 bit) with the following error:

/tmp/pear/temp/APC/php_apc.c:959: error: duplicate ‘static’
make: *** [php_apc.lo] Error 1
ERROR: `make' failed

I used sudo apt-get install php-apc then restarted apache. Works fine. Hope that helps someone else with the same problem.

Mark

  • reply

Anonymous (not verified)

Same error here on ubuntu

Tue, 2010/08/24 - 07:23

Same error here on ubuntu 10.04 64 bit

found this bug report http://pecl.php.net/bugs/bug.php?id=16078
Sollution sudo pecl install apc-beta
worked perfectly

  • reply

Tom129 (not verified)

Old/New

Thu, 2011/10/13 - 11:14

Dotdeb has php4-apc and php5-apc packages of course usable only when you use php from dotdeb packages. But for me the biggest problem is that APC is not compatible with Zend Optimizer which in fact is not optimizer/cache, it enables usage of encoded php files.
So I tried to compile e accelerator and it works great. Compiling is very easy, you only need to install php{4,5}-dev.
Search for few benchmarks it seems e Accelerator is very close to APC in performance.

  • reply

Pages

  • « first
  • ‹ previous
  • 1
  • 2
  • 3

Current

Pandemic

  • COVID-19
  • Coronavirus

Search

Site map

Contents

  • Family
    • Khalid
    • Ancestry
    • Extended
  • Friends
  • Nokat نكت
  • Writings
    • Cooking
    • Culture
    • Science
    • History
    • Linguistics
    • Media
    • Literature
    • Politics
    • Humor
    • Terrorism
    • Business
    • Philosophy
    • Religion
    • Children
  • Technology
    • Linux
    • Arabization
    • Drupal
      • Association
    • Software
    • Internet
    • Technology in Society
    • Digital Archeology
    • NCR History
    • MidEast Internet
    • Programming
    • Saudi ISPs
    • Miscellaneous
  • Places
    • Canada
      • Weather
    • Egypt
      • Cuisine
      • Alexandria
      • E.G.C.
    • USA
    • Saudi Arabia
  • Interests
    • Astronomy
    • Fishing
    • Photography
    • Snorkeling
    • Nature
    • Photomicroscopy
  • Miscellany

In Depth

  • al-Hakim bi Amr Allah: Fatimid Caliph of Egypt الحاكم بأمر الله
  • Alexandria, Egypt
  • Arabic on the Internet
  • Articles on the history of Muslims and Arabs in the Iberian Peninsula تاريخ المسلمين و العرب في الأند
  • DIY GOTO Telescope Controller With Autoguiding and Periodic Error Correction
  • E.G.C. English Girls College in Alexandria, Egypt
  • Egyptian Cuisine, Food and Recipes مأكولات مصرية
  • George Saliba: Seeking the Origins of Modern Science?
  • Internet Scams and Fraud
  • Mistaken for an Arab or Muslim: Absurdities of being a victim in the War on Terror
  • Mistaken Identity: How some people confuse my site for others
  • One People's Terrorist Is Another People's Freedom Fighter
  • Overview of Google's Technologies
  • Photomicroscopy
  • Pseudoscience: Lots of it around ...
  • Resources for using Google Adsense with Drupal
  • Rockwood Conservation Area, Southern Ontario
  • Selected Symbolic Novels And Movies
  • Snorkeling the Red Sea near Jeddah
  • Updates and Thoughts on the Egyptian Revolution of 2011

Recent Content

Most recent articles on the site.

  • Origin Of COVID-19: Natural Spillover, Lab Leak Or Biological Weapon?
  • Kamal Salibi and the "Israel from Yemen" theory
  • How To Upgrade HomeAssistant Core In A Python Venv Using uv
  • Ancestry - Paternal Side
  • Review of Wait Water Saver For Whole House Humidifiers
more

Most Comments

Most commented on articles ...

  • Another scam via Craigslist: offering more than asking price
  • Warning to female tourists thinking of marrying Egyptians
  • Craigslist classified for used car: Cheque fraud scam
  • Winning the lottery scam email: World Cup South African lottery
  • Email Scam: BMW 5 Series car and lottery winning
more

About Khalid

Various little bits of information ...

  • Khalid Baheyeldin: brief biography
  • Presentations and Talks
  • Youtube Videos
  • GitHub Projects
  • Drupal.org Profile
  • Astrophotography @ Flickr

Sponsored Links

Your Link Ad Here

Tags

Android Mobile Ubuntu Sony OnStep OpenWRT Router Ericsson COVID-19 Rogers Coronavirus Arabic Kubuntu Home Assistant GSM Telescope tablet Spectrum Scam Python 419 Laptop Firefox DIY CPU Conspiracy Comet Balkanization backup App
More

© Copyright 1999-2025 The Baheyeldin Dynasty. All rights reserved.
You can use our content under the Terms of Use.
Please read our privacy policy before you post any information on this site.
All posted articles and comments are copyright by their owner, and reflect their own views and opinions, which may not necessarily be consistent with the views and opinions of the owners of The Baheyeldin Dynasty.

Web site developed by 2bits.com Inc.