1

I'm trying to install the PECL memcache extension in MAMP on my Mac running 10.9 (Mavericks). I just upgraded to MAMP 3.0 and need to reinstall.

I ran sudo pecl install memcache in Terminal but my paths seem to be stuffed up and it cannot find php.h. It seems to look in /Applications/MAMP/bin/php/php5.5.10/include/php/main/php.h. The /Applications/MAMP/bin/php/php5.5.10/include/ does not exist.

Here's my terminal logs. Has anyone else had this issue?

$ 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
Ben Sinclair
  • 3,896
  • 7
  • 54
  • 94

2 Answers2

8

The answer from lollerskates666 may work, but it's a bad idea, because the version of PHP that Xcode uses might not be the same as the version of PHP that MAMP uses. What you really need to do is download the PHP source (ensure you're downloading the exact same PHP version as MAMP is using), and copy the source you downloaded into the /include/ directory for your MAMP php version.

Eg for PHP 5.5.10, the steps would be:

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

  2. Unzip the archive, then rename the folder from php-5.5.10 to just php.

  3. Go to /Applications/MAMP/bin/php/php5.5.10/ in finder, or via terminal.

  4. If a folder called include doesn't already exist in that location, create it.

  5. Move the php folder from step 2, into the include directory mentioned in step 4.

You should now have a bunch of stuff in /Applications/MAMP/bin/php/php5.5.10/include/php/, including the /main/php.h file.

joshua.paling
  • 13,762
  • 4
  • 45
  • 60
7

Try creating a symbolic link to the directory containing Xcode php development headers

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

Correct the paths to match the versions of your OS and PHP

Timo
  • 2,740
  • 1
  • 24
  • 22
  • You're a legend! All worked this time, no errors. Only issue was it added the `memcache.so` file to `/usr/lib/php/extensions/no-debug-non-zts-20100525/` so I manually copied and pasted it to `/Applications/MAMP/bin/php/php5.5.10/lib/php/extensions/no-debug-non-zts-20121212`. I've added `extension=memcache.so` to my php.ini file and restarted MAMP but to no avail. The `Memcache` class does not exist. Have I moved it incorrectly? Appreciate your help! – Ben Sinclair Apr 01 '14 at 23:56
  • Check my [question regarding the same issue](http://stackoverflow.com/questions/22715941/memcached-is-installed-on-php-5-3-28-on-mamp-3-0-3-but-not-working). Do you see similar error in Apache logs? – Timo Apr 03 '14 at 08:32
  • No, there doesn't seem to be any errors when I restart my server. Apache logs are pretty clean. Is there anything I can send you to help determine where it's breaking? Really appreciate you taking the time to help me :) – Ben Sinclair Apr 04 '14 at 00:39
  • Just saw your answer on your question above. I have got memcached to work too. Maybe I'll just have to switch. Did you find much difference or pretty much the same? – Ben Sinclair Apr 04 '14 at 00:40
  • I had lots of trouble setting up the environment and while I managed to get the memcached work, there were other weird errors. Finally I installed [PHP with Homebrew following these instructions](http://justinhileman.info/article/reinstalling-php-on-mac-os-x/) and everything is running smoothly. I am no expert on this matter so I don't know if there is something wrong with MAMP 3 or does the linking of Xcode 5.1 headers create problems. I had similar setup earlier on my previous laptop running on MAMP 2 and it was working nicely without problems. – Timo Apr 04 '14 at 06:49
  • 1
    DON'T Symlink to Xcode's PHP. It's a bad idea, because XCode isn't neccessarily using the same version of PHP as MAMP (and certainly can't be guaranteed to in future). See my answer below. – joshua.paling Jun 03 '14 at 03:06