Heine

  • Home
  • Drupal
  • About
Home

Alternative PHP Cache on Debian Sarge

Heine —Tue, 2007/02/20 - 22:40

This is a repost about a different (now defunct) server.

Khalid wrote a small guide to Installing the Alternative PHP Cache on Ubuntu Dapper and Debian. The installation on Debian 3.1 (Sarge), requires a few extra steps though.

Make sure you have the proper permissions (# denotes the root prompt) and issue the following commands:

# aptitude update
# aptitude install apache2-dev php4-dev php4-pear make
[lots of text. aptitude will probably tell you it elected to install apache2-threaded-dev]
# ln -s /usr/bin/apxs2 /usr/bin/apxs

If you use php5, make sure to select the appropriate packages.

The next step in Khalids guide will fail:

# pecl install apc
-bash: pecl: command not found

Why? The pear version on Debian Sarge is to old. Attempting to upgrade PEAR automatically will fail:

# pear upgrade pear
downloading PEAR-1.4.11.tgz ...
Starting to download PEAR-1.4.11.tgz (283,272 bytes)
..........................................................done: 283,272 bytes
requires package `PEAR' >= 1.3.3
PEAR: Dependencies failed
#

Arg! Calm down. It is easy... You just need the right incantation:

# pear upgrade pear-1.3.3
[pear is upgraded to 1.3.3]
# pear upgrade Archive_Tar
# pear upgrade pear
[pear is upgraded to the latest version]
# pear upgrade-all
[all pear default packages are updated]

You may need to add @ini_set('memory_limit', '64M'); to /usr/share/php/pearcmd.php if you get "Fatal error: allowed memory size of [XXXX] bytes exhausted ...". Also, Catch notes below that pear upgrade pear doesn't work when /usr/bin/pear is the current directory.

Now you can continue with the rest of the guide and install APC:

# pecl install apc
[answer the questions before you go grab a coffee!]

Now pecl install appended all installed .so files to the end of my current php.ini so I had to remove a number of duplicates before I could restart Apache. You may need to do the same or add the block below to php.ini before you restart Apache:

extension=apc.so
apc.enabled=1
apc.shm_segments=1
apc.optimization=0
apc.shm_size=128
apc.ttl=7200
apc.user_ttl=7200
apc.num_files_hint=1024
apc.mmap_file_mask=/tmp/apc.XXXXXX
apc.enable_cli=1

With php.ini properly setup you can restart Apache:

# /etc/init.d/apache2 restart

Congratulations. You've installed APC! As you will experience, the speed increase is quite significant. Combined with the MySQL query cache, .sock files and normal page caching, the total page generation time for the Drupal-based front page is down to 8 milliseconds for anonymous users.

  • Drupal
  • PHP
  • Performance

Comments

Nice article

Submitted by styro (not verified) on Thu, 2007/03/01 - 04:04

Thanks Heine, that was very helpful.

Also on Debian Sarge I had to install the g++ Debian package to get the APC build working, and the Structures_Graph PEAR package to get pear upgraded.

The whole process installed a whole lot of stuff I wouldn't want living on a minimalist production web server. But the good news was that the apc.so extension seems to be completely self contained and if you build it on a non production machine then upload just the apc.so file it should work (it did for me). Nice.

I'm looking forward to Etch where hopefully the dh-make-php Debian package could be as much a life saver for more complex pear builds as the dh-make-perl one is for those pesky CPAN modules I sometimes need built to run 3rd party apps (eg GeoIP for awstats).

Cheers
Anton

just followed this. Not a

Submitted by catch (not verified) on Tue, 2007/04/03 - 00:24

just followed this. Not a fault of the HOWTO, but pear upgrade pear doesn't work from within /usr/bin/pear - it took me ages to work out what was going on (like 20 minutes). Otherwise this was very, very smooth.

Recent posts

  • Teampassword manager's password generator is biased
  • Other vectors for SA-CORE-2014-005?
  • Lazy loading: hook_hook_info is for hook owners only.
  • "Always offline" problem in EA's Origin due to antivirus
  • From bug to exploit - Bakery SSO
more

Security reviews

I provide security reviews of custom code, contributed modules, themes and entire sites via LimoenGroen.

Contact us for a quote.

Follow @ustima

Copyright © 2021 by Heine Deelstra. All rights reserved.

  • Home
  • Drupal
  • About