After installing APC on CentOS 5 via pecl install apc, APC does not load when PHP is called from the CLI (when called from apache, it loads without any problems).

The error I get is:

root@server [~]# php
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/apc.so' - /usr/lib64/php/modules/apc.so: undefined symbol: pcre_exec in Unknown on line 0 

I have searched the web for a solution, and have found many people have had this problem. However, I was unable to find a solution that worked for me.

  • Is pcre.h installed? libpcre I think is the parent library. – Tom O'Connor Dec 4 '11 at 22:38
  • The package pcre-devel is installed via yum. – xaav Dec 4 '11 at 22:40
  • Why would it even make sense for it to run from the CLI? IF APC isn't staying in memory, then it isn't going to do anything useful as a cache. – Zoredache Dec 5 '11 at 2:10
  • If PHP is called via mod_fcgid, then the PHP processes will be serving more than one request. – xaav Dec 6 '11 at 2:43

I fixed the problem by removing APC via the pecl installer, then reinstalling it with the pear installer.

pecl uninstall apc
pear install pecl/apc

Run which php, then locate php. If you have multiple PHP binaries on your system (this can happen quite easily if you install one version via your package manager, then compile another via source), the extensions will not likely be compatible between versions. Removing the incorrect PHP binary should allow this to work properly.

  • The output from which php is /usr/bin/php, but the output from locate php is too long to read, so I'll have to find other methods of finding other php binaries. – xaav Dec 4 '11 at 22:58
  • I was unable to find any other PHP binaries on the system. – xaav Dec 4 '11 at 23:09

You simply need to add the following directive to your apc.ini file:

apc.enable_cli = 1 

Fix for this relatively simple:

Copy the existing file /etc/php.d/apc.ini to /tmp

cp /etc/php.d/apc.ini /tmp

Remove the installed package

yum remove php-pecl-apc

Install the apc using pecl itself

pecl install apc

Move back file apc.ini

mv /tmp/apc.ini /etc/php.d/apc.ini

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.