2013-04-26 17:00
浏览 77


I would like install the Alternative PHP Cache (APC) on my mac.

With PECL this is supposedly a rather painless operation.

All one needs to do is:

sudo pecl install apc

As others have reported on the interwebs, apc depends on pcre, the PHP compatible regular expression library.

Now I've installed the latest version of PHP and PEAR/PECL using fink. I've also installed pcre using fink:

i   pcre                     8.21-2             Perl Compatible Regular Expressions Library

The problem is, when trying to use sudo pecl install apc, pecl is checking the default directories for the pcre libraries and not looking in /sw:

cc -D_GNU_SOURCE -I. -I/private/tmp/pear/temp/APC -DPHP_ATOM_INC -I/private/tmp/pear/temp/pear-build-rootPtlYda/APC-3.1.13/include -I/private/tmp/pear/temp/pear-build-rootPtlYda/APC-3.1.13/main -I/private/tmp/pear/temp/APC -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /private/tmp/pear/temp/APC/apc.c  -fno-common -DPIC -o .libs/apc.o
In file included from /private/tmp/pear/temp/APC/apc.c:45:
/usr/include/php/ext/pcre/php_pcre.h:29:10: fatal error: 'pcre.h' file not found
#include "pcre.h"
1 error generated.
make: *** [apc.lo] Error 1
ERROR: `make' failed

Hence I have two questions:

  1. Is there an environment variable I can set to point to the fink pcre libraries for compiling apc?
  2. Where exactly is fink even putting pcre?


I see this question regarding Macports:

sudo pecl install apc error on os x lion

In this question, the answer involves symlinking the needed pcre headers to their expected location for PECL.

I tried a similar solution. For the fink approach, the symlink command here is:

sudo ln -s /sw/include/pcre.h /usr/include/

But still this did not work. The installation of APC via PECL does not seem to be able to find this header file.

And I should add, indeed, the pcre.h header file is found in /sw/include/pcre.h.

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dt888999 2013-04-26 17:07

    I believe I found the answer.

    Inspecting the file that is expecting pcre.h (/usr/include/php/ext/pcre/php_pcre.h:29) I see this:

    #include "pcre.h"

    Perhaps there is a way to add an include path during a PECL installation, but I am unaware of how to do so.

    My solution then was to simply place the symlink to pcre.h in the directory containing this offending source file. Like so:

    sudo ln -s /sw/include/pcre.h /usr/include/php/ext/pcre/

    That did it. Maybe folks have a more elegant way to do this but for others with this problem, this should get the job done.


    Actually, I should note that my above information is incomplete and will not work.

    The problem is, one must be certain to first install the fink package php5-dev.

    Frankly, I think the fink package php-pear should be made to have php5-dev as a dependency. It does not, and I for the moment am not familiar in maintaining fink packages so this will have to do.

    The consequences of not having this package is simply that the requisite header files needed when compiling APC are not available for fink version of php. They are, fortunately or unfortunately, available for the Mountaion Lion included PHP. The consequences of this is that although APC will compile, it will be linked against the wrong version of PHP.

    After one updates their php.ini with the requisite, as instructed by the conclusion of the apc installation, the following message will be found in their apache error file. (For Fink this is at /sw/var/log/apache2/error.log):

    PHP Startup: apc: Unable to initialize module
    Module compiled with module API=20090626
    PHP    compiled with module API=20100525

    The solution to this was to simply to sudo pecl uninstall apc then do sudo fink install php5-dev, then finally do sudo pecl install apc.

    The final install of apc will use the include files added by php5-dev and all will be well.

    Then you can confidently add to /sw/etc/php5/apache2/php.ini.

    One more thing

    Also note that my above instructions for for symlinking the pcre.h file have to be modified slightly to be:

    sudo ln -s /sw/include/pcre.h /sw/include/php5/ext/pcre

    The fact that pecl was messing with things in /usr and not a /sw directory should have tipped things off for me.

    解决 无用
    打赏 举报

相关推荐 更多相似问题