【问题标题】:Installing memcache PECL extension on MAMP Mac OX X 10.9在 MAMP Mac OS X 10.9 上安装 memcached PECL 扩展
【发布时间】:2014-03-25 09:29:26
【问题描述】:

我正在尝试在运行 10.9 (Mavericks) 的 Mac 上的 MAMP 中安装 PECL memcache 扩展。我刚刚升级到 MAMP 3.0,需要重新安装。

我在终端中运行了sudo pecl install memcache,但我的路径似乎被塞满了,找不到php.h。它似乎在查看/Applications/MAMP/bin/php/php5.5.10/include/php/main/php.h/Applications/MAMP/bin/php/php5.5.10/include/ 不存在。

这是我的终端日志。有其他人遇到过这个问题吗?

$ sudo pecl install memcache
downloading memcache-2.2.7.tgz ...
Starting to download memcache-2.2.7.tgz (36,459 bytes)
..........done: 36,459 bytes
11 source files, building
WARNING: php_bin /Applications/MAMP/bin/php/php5.5.10/bin/php appears to have a suffix /php5.5.10/bin/php, but config variable php_suffix does not match
running: phpize
grep: /Applications/MAMP/bin/php/php5.5.10/include/php/main/php.h: No such file or directory
grep: /Applications/MAMP/bin/php/php5.5.10/include/php/Zend/zend_modules.h: No such file or directory
grep: /Applications/MAMP/bin/php/php5.5.10/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
Enable memcache session handler support? [yes] : no
building in /private/tmp/pear/install/pear-build-roottck15S/memcache-2.2.7
running: /private/tmp/pear/install/memcache/configure --enable-memcache-session=no
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-apple-darwin13.1.0
checking host system type... x86_64-apple-darwin13.1.0
checking target system type... x86_64-apple-darwin13.1.0
checking for PHP prefix... /Applications/MAMP/bin/php/php5.5.10
checking for PHP includes... -I/Applications/MAMP/bin/php/php5.5.10/include/php -I/Applications/MAMP/bin/php/php5.5.10/include/php/main -I/Applications/MAMP/bin/php/php5.5.10/include/php/TSRM -I/Applications/MAMP/bin/php/php5.5.10/include/php/Zend -I/Applications/MAMP/bin/php/php5.5.10/include/php/ext -I/Applications/MAMP/bin/php/php5.5.10/include/php/ext/date/lib
checking for PHP extension directory... /Applications/MAMP/bin/php/php5.5.10/lib/php/extensions/no-debug-non-zts-20121212
checking for PHP installed headers prefix... /Applications/MAMP/bin/php/php5.5.10/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking whether to enable memcache support... yes, shared
checking whether to enable memcache session handler support... no
checking for the location of ZLIB... no
checking for the location of zlib... /usr
checking for memcache session support... disabled
checking for ld used by cc... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
checking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld... no
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 196608
checking command to parse /usr/bin/nm output from cc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking if cc supports -fno-rtti -fno-exceptions... yes
checking for cc option to produce PIC... -fno-common
checking if cc PIC flag -fno-common works... yes
checking if cc static flag -static works... no
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin13.1.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/sh /private/tmp/pear/install/pear-build-roottck15S/memcache-2.2.7/libtool --mode=compile cc  -I. -I/private/tmp/pear/install/memcache -DPHP_ATOM_INC -I/private/tmp/pear/install/pear-build-roottck15S/memcache-2.2.7/include -I/private/tmp/pear/install/pear-build-roottck15S/memcache-2.2.7/main -I/private/tmp/pear/install/memcache -I/Applications/MAMP/bin/php/php5.5.10/include/php -I/Applications/MAMP/bin/php/php5.5.10/include/php/main -I/Applications/MAMP/bin/php/php5.5.10/include/php/TSRM -I/Applications/MAMP/bin/php/php5.5.10/include/php/Zend -I/Applications/MAMP/bin/php/php5.5.10/include/php/ext -I/Applications/MAMP/bin/php/php5.5.10/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /private/tmp/pear/install/memcache/memcache.c -o memcache.lo
mkdir .libs
 cc -I. -I/private/tmp/pear/install/memcache -DPHP_ATOM_INC -I/private/tmp/pear/install/pear-build-roottck15S/memcache-2.2.7/include -I/private/tmp/pear/install/pear-build-roottck15S/memcache-2.2.7/main -I/private/tmp/pear/install/memcache -I/Applications/MAMP/bin/php/php5.5.10/include/php -I/Applications/MAMP/bin/php/php5.5.10/include/php/main -I/Applications/MAMP/bin/php/php5.5.10/include/php/TSRM -I/Applications/MAMP/bin/php/php5.5.10/include/php/Zend -I/Applications/MAMP/bin/php/php5.5.10/include/php/ext -I/Applications/MAMP/bin/php/php5.5.10/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /private/tmp/pear/install/memcache/memcache.c  -fno-common -DPIC -o .libs/memcache.o
/private/tmp/pear/install/memcache/memcache.c:26:10: fatal error: 'php.h' file not found
#include "php.h"
         ^
1 error generated.
make: *** [memcache.lo] Error 1
ERROR: `make' failed

【问题讨论】:

    标签: mamp libmemcache


    【解决方案1】:

    来自 lollerskates666 的答案可能有效,但这是个坏主意,因为 Xcode 使用的 PHP 版本可能与 MAMP 使用的 PHP 版本不同。您真正需要做的是下载 PHP 源代码(确保您下载的 PHP 版本与 MAMP 使用的完全相同),然后将下载的源代码复制到您的 MAMP php 版本的 /include/ 目录中。

    例如,对于 PHP 5.5.10,步骤如下:

    1. http://us2.php.net/get/php-5.5.10.tar.gz/from/a/mirror下载PHP 5.5.10

    2. 解压缩存档,然后将文件夹从 php-5.5.10 重命名为 php

    3. 在查找器中或通过终端转到/Applications/MAMP/bin/php/php5.5.10/

    4. 如果该位置不存在名为 include 的文件夹,请创建它。

    5. 将步骤 2 中的 php 文件夹移动到步骤 4 中提到的 include 目录中。

    您现在应该在/Applications/MAMP/bin/php/php5.5.10/include/php/ 中有一堆东西,包括/main/php.h 文件。

    【讨论】:

      【解决方案2】:

      尝试创建指向包含 Xcode php 开发头文件的目录的符号链接

      ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include /Applications/MAMP/bin/php/php5.5.10

      更正路径以匹配您的操作系统和 PHP 版本

      【讨论】:

      • 你是个传奇!这次一切正常,没有错误。唯一的问题是将memcache.so 文件添加到/usr/lib/php/extensions/no-debug-non-zts-20100525/,所以我手动将其复制并粘贴到/Applications/MAMP/bin/php/php5.5.10/lib/php/extensions/no-debug-non-zts-20121212。我已将extension=memcache.so 添加到我的 php.ini 文件并重新启动 MAMP 但无济于事。 Memcache 类不存在。我是否错误地移动了它?感谢您的帮助!
      • 查看我的question regarding the same issue。您是否在 Apache 日志中看到类似的错误?
      • 不,我重新启动服务器时似乎没有任何错误。 Apache 日志非常干净。有什么我可以寄给你来帮助确定它在哪里坏掉的吗?非常感谢您花时间帮助我:)
      • 刚刚看到您对上述问题的回答。我也让 memcached 工作。也许我只需要切换。您发现有很大不同还是几乎相同?
      • 不要符号链接到 Xcode 的 PHP。这是个坏主意,因为 XCode 不一定使用与 MAMP 相同的 PHP 版本(当然不能保证将来会这样做)。请参阅下面的答案。
      猜你喜欢
      • 1970-01-01
      • 2014-02-12
      • 2011-07-29
      • 1970-01-01
      • 2017-05-23
      • 2014-04-29
      • 2013-11-02
      • 2013-11-11
      相关资源
      最近更新 更多