Установка расширения memcache PECL на MAMP Mac OX X 10.9

Я пытаюсь установить расширение кэша памяти PECL в MAMP на моем Mac под управлением 10.9 (Mavericks). Я только что обновился до 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

person Ben Sinclair    schedule 25.03.2014    source источник


Ответы (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.

person Timo    schedule 28.03.2014
comment
Ты легенда! На этот раз все заработало, ошибок нет. Единственная проблема заключалась в том, что он добавил 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 не существует. Неправильно ли я его переместил? Ценю вашу помощь! - person Ben Sinclair; 02.04.2014
comment
Проверьте мой вопрос по той же проблеме. Вы видите аналогичную ошибку в журналах Apache? - person Timo; 03.04.2014
comment
Нет, при перезапуске сервера никаких ошибок не возникает. Журналы Apache довольно чистые. Могу ли я что-нибудь отправить вам, чтобы определить, где он ломается? Спасибо, что нашли время помочь мне :) - person Ben Sinclair; 04.04.2014
comment
Только что видел ваш ответ на свой вопрос выше. У меня тоже есть memcached для работы. Может, мне просто придется переключиться. Вы заметили большую разницу или почти то же самое? - person Ben Sinclair; 04.04.2014
comment
У меня было много проблем с настройкой среды, и хотя мне удалось заставить работать memcached, были и другие странные ошибки. Наконец, я установил PHP с Homebrew, следуя этим инструкциям, и все работает плавно. Я не являюсь экспертом в этом вопросе, поэтому я не знаю, что-то не так с MAMP 3 или связывание заголовков Xcode 5.1 создает проблемы. Ранее у меня была аналогичная установка на моем предыдущем ноутбуке, работающем на MAMP 2, и он работал нормально без проблем. - person Timo; 04.04.2014
comment
НЕ используйте символические ссылки для Xcode PHP. Это плохая идея, потому что XCode не обязательно использует ту же версию PHP, что и MAMP (и, конечно, не может быть гарантирован в будущем). Смотрите мой ответ ниже. - person joshua.paling; 03.06.2014

Ответ от lollerskates666 может сработать, но это плохая идея, потому что версия PHP, которую использует Xcode, может не совпадать с версией PHP, которую использует MAMP. Что вам действительно нужно сделать, так это загрузить исходный код PHP (убедитесь, что вы загружаете ту же версию PHP, что и MAMP), и скопируйте загруженный вами источник в каталог /include/ для вашей версии MAMP php.

Например, для PHP 5.5.10 шаги будут следующими:

  1. Загрузите PHP 5.5.10 с сайта http://us2.php.net/get/php-5.5.10.tar.gz/from/a/mirror

  2. Распакуйте архив, затем переименуйте папку с php-5.5.10 в просто php.

  3. Перейдите к /Applications/MAMP/bin/php/php5.5.10/ в поисковике или через терминал.

  4. Если папка с именем include еще не существует в этом месте, создайте ее.

  5. Переместите папку php из шага 2 в каталог include, упомянутый в шаге 4.

Теперь у вас должна быть куча вещей в /Applications/MAMP/bin/php/php5.5.10/include/php/, включая файл /main/php.h.

person joshua.paling    schedule 03.06.2014