dongluni0568 2013-04-26 17:00
浏览 77
已采纳

使用PECL和Fink安装备用PHP缓存

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?

UPDATE

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.

    VERY IMPORTANT UPDATE

    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 extension=apc.so, 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 extension=apc.so 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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建