Using PECL-APC with Gallery

I recently decided to use a php cache to speed up the response of my websites. I decided to use PECL-APC (Alternative PHP Cache) and I did the following

  1. Installing PECL-APC
  2. Check Installation
  3. Fix Problems with PECL-APC and Gallery

1. Installing PECL-APC

I’m using PHP5 and Gentoo. The dev-php5/pecl-apc package is masked by the ~x86 keyword and so I have added this line to /etc/portage/package.keywords

dev-php5/pecl-apc ~x86

I then emerged this package using the following command

emerge dev-php5/pecl-apc

2 . Check installation

You can then check this is working by creating a file on your webserver with this line in it

<?php phpinfo(); ?>

and navigating to the page. Do a search on this page for apc. If it’s there then it should be working.

3. Fix Problems with PECL-APC and Gallery

Unfortunately after installing pecl-apc my Gallery installation began to give me the following error.

Fatal error: Call to undefined method GalleryAlbumItem::onLoad() in modules/core/classes/helpers/GalleryEntityHelper_simple.class on line 102

The solution to this problem was to make sure pecl-apc did not cache certain scripts in the Gallery installation, namely the .class files. I edited the /etc/php/apache2-php5/ext/apc.ini file and made the following change.


I then restarted apache and the problem was gone.

Useful Links

4 Responses to “Using PECL-APC with Gallery”

  1. akin0 Says:

    One point to check is that you requiere a mpm-prefork apache2 install to put to work APC ….

  2. gstead Says:

    This page was helpful, especially as I also use Gentoo.

    However, I think you phpinfo command has a space in the wrong place. I believe it should be:

    best regards,

  3. Administrator Says:

    Thanks gstead, fixed now!

  4. Matt Farmer Says:

    Just an update to akin0’s comment: This is no longer a use variable, but instead can by configured by putting ‘APACHE2_MPMS=”prefork”‘ in your /etc/make.conf file. When you do this, you’ll need to have ‘CONFIG_SYSVIPC=y’ in your kernel config (check with ‘zgrep CONFIG_SYSVIPC /proc/config.gz’), and you can not have the threads variable enabled for apache ( add the following to your /etc/portage/package.use : ‘www-servers/apache -threads’ ).

Leave a Reply