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

Nick (not verified)

Memory limit

Tue, 2006/06/20 - 22:51

When you say the memory limit doesn't work by changing the php.ini file, did you change the /etc/php5/cli/php.ini? My dapper system has separate ini files, and I've had to change the command line memory limit in the past to get some pear install stuff to work.

  • reply

Khalid

Tried them all

Wed, 2006/06/21 - 09:22

Yes, I tried them all, but still did not work:

# grep memory_limit /etc/php*/*/php.ini
/etc/php5/apache2/php.ini:memory_limit = 16M 
/etc/php5/cgi/php.ini:memory_limit = 16M
/etc/php5/cli/php.ini:memory_limit = 16M 

This is a problem on amd64 Dapper only. The other two machines worked fine.

  • reply

christo (not verified)

Ubuntu server

Tue, 2006/10/03 - 09:44

Just did this on my ubuntu server remotely from work, great write up.

Don't forget to apt-get install make, g++ and gcc -- actually spent longer working out g++ wasn't installed on my minimalist server.

  • reply

Matthew (not verified)

php.ini now uses conf.d

Tue, 2006/11/21 - 21:36

For php5 + apache2 + debian etch, the APC activation "extension=apc.so" should now be placed in /etc/php5/conf.d/apc.ini instead of /etc/php5/apache2/php.ini. This is because, as of version 5.1.6-5, php in debian has been reworked to use a conf.d style configuration for extensions. This change should hit Ubuntu 7.04 "Feisty", and also applies to the latest versions of php4. More here.

  • reply

Heine (not verified)

Debian Sarge

Thu, 2006/11/23 - 02:07

When running Debian Sarge a few extra steps are needed:

You have to upgrade pear before pecl is available. Before:

pecl install apc

Upgrade pear to 1.3.3 (< versions do not upgrade automatically to the latest)

pear upgrade pear-1.3.3

Next upgrade to the latest pear (or issue pear upgrade-all)

pear upgrade pear

During this process you may need to increase the memory limit as described to as high as 64M. After this, pecl is available.

  • reply

Anonymous (not verified)

while installing APC on my

Thu, 2007/11/01 - 08:00

while installing APC on my ubuntu machine i am getting bellow errors:
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
The output of apxs follows
./configure: line 3845: apxs: command not found
configure: error: Aborting

but i installed perl also . please help me

  • reply

Anonymous (not verified)

Installed on etch without a

Fri, 2007/04/20 - 03:09

Installed on etch without a problem. For now works ok.

Thanks

  • reply

Matt (not verified)

Possible error in install

Sat, 2007/05/12 - 20:31

Excellent tutorial for installing APC!

I had issues finding the apxs program. What worked for me was installing the apache2-threaded-dev package instead of apache2-dev (which was not found in my repositories). Also, with this package I did not need to use the symbolic link instruction.

Thanks again for the guide.

  • reply

Shrinivasan (not verified)

Thanks

Mon, 2007/06/25 - 06:30

Hi.

A lot of thanks to u.
My web app is now working in rocket speed.
Great article.

  • reply

kpk (not verified)

hai all, I am not able to

Fri, 2007/11/02 - 04:17

hai all,

I am not able to finding the problem while installing apc.And I am getting below errors. please any one can help me.

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
The output of /usr/bin/ follows
/tmp/pear/cache/APC-3.0.15/configure: line 3845: /usr/bin/: is a directory
configure: error: Aborting
ERROR: `/tmp/pear/cache/APC-3.0.15/configure --with-apxs=/usr/bin/' failed

and i installed perl like below
root@prashanth-desktop:~# which perl
perl perl5.8.8 perlbug perlcc perldoc perlivp
root@prashanth-desktop:~# which perl
/usr/bin/perl
root@prashanth-desktop:~#

then i configured /etc/php5/conf.d/apc.ini instead of /etc/php5/apache2/php.ini.

thanks

  • reply

Pages

  • « first
  • ‹ previous
  • 1
  • 2
  • 3
  • next ›
  • last »

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.