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.

link|improve this question
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
feedback

2 Answers

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.

link|improve this answer
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
feedback

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

pecl remove apc
pear install pecl/apc
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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