Skip to content

Instantly share code, notes, and snippets.

@ryanjbonnell
Last active March 23, 2023 18:01
Show Gist options
  • Save ryanjbonnell/3880048 to your computer and use it in GitHub Desktop.
Save ryanjbonnell/3880048 to your computer and use it in GitHub Desktop.
Install Memcache on Mac OS X 10.8 "Mountain Lion"
# memcached requires libevent
cd /usr/local/src
curl -L -O http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.17-stable.tar.gz
tar -xvzf libevent-2.0.17-stable.tar.gz
cd libevent-2.0.17-stable*
./configure
make
sudo make install
# Compile memcached utility
cd /usr/local/src
curl -L -O http://memcached.googlecode.com/files/memcached-1.4.13.tar.gz
tar -xvzf memcached-1.4.13.tar.gz
cd memcached-1.4.13*
./configure
make
sudo make install
# Create .bash_profile alias to start memcached as needed
alias m="memcached -d -m 24 -p 11211"
# Install autoconfig
cd /usr/local/src
curl -L -O http://gnu.mirrors.hoobly.com/gnu/autoconf/autoconf-2.69.tar.gz
tar xzf autoconf-2.69.tar.gz
cd autoconf-2.69
./configure --prefix=/usr/local
make
sudo make install
# Compile and copy memcached.so module
cd /usr/local/src
curl -O http://pecl.php.net/get/memcache-2.2.7.tgz
tar -xvzf memcache-2.2.7.tgz
cd memcache-2.2.7
phpize
./configure --enable-memcache
make
sudo make install
# If using MAMP
# cp modules/memcache.so /Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/
# emacs /Applications/MAMP/bin/php/php5.3.6/conf/php.ini # add line: extension=memcache.so
# If using Apache2
# sudo emacs /etc/php.ini # add line: extension=memcache.so
@axlotl
Copy link

axlotl commented Jul 9, 2013

@traday: that doesn't install the php extension. Also I think if you do install memcached through homebrew you also need to install libmemcached likewise.

More generally, the manual build of the extension as described here worked for me when pecl didn't. Configure flag I'm guessing. Thanks.

@tinagu
Copy link

tinagu commented Oct 21, 2013

Nice. This works

@gguardin
Copy link

Ops... I get this error at line 16 (make)

gcc -g -O2 -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -o memcached memcached-memcached.o memcached-hash.o memcached-slabs.o memcached-items.o memcached-assoc.o memcached-thread.o memcached-daemon.o memcached-stats.o memcached-util.o memcached-cache.o -levent
clang: error: argument unused during compilation: '-pthread'
make[2]: *** [memcached] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

Any ideas?

Thanks

@inspire22
Copy link

Def use homebrew instead

@felipebcs
Copy link

Thanks for this gist!

Just for the record if anyone needs it:

For my XAMPP installation I used the following to compile with the proper PHP binaries for my case:

curl -L -O http://pecl.php.net/get/memcache-2.2.7.tgz
tar -xvzf memcache-2.2.7.tgz
cd memcache-2.2.7
/Applications/XAMPP/xamppfiles/bin/phpize
./configure --enable-memcache --with-php-config=/Applications/XAMPP/xamppfiles/bin/php-config
make
sudo make install

(I've installed libevent and memcached using macports and I used this code to compile the .so and add to PHP)

@vivekkodu
Copy link

While running the make step of the memcached i am facing following error:
/Library/Developer/CommandLineTools/usr/bin/make all-recursive
Making all in doc
/Library/Developer/CommandLineTools/usr/bin/make all-am
make[3]: Nothing to be done for `all-am'.
gcc -g -O2 -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -o memcached memcached-memcached.o memcached-hash.o memcached-slabs.o memcached-items.o memcached-assoc.o memcached-thread.o memcached-daemon.o memcached-stats.o memcached-util.o memcached-cache.o -levent
clang: error: argument unused during compilation: '-pthread'
make[2]: *** [memcached] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

Any suggestions on how to resolve this??

@ecamaj
Copy link

ecamaj commented Dec 22, 2014

I'm also getting this -pthread error. That makes three of us.

Anyone can help?

@mibalan
Copy link

mibalan commented Mar 30, 2015

@ecamaj actually four :)

@mibalan
Copy link

mibalan commented Mar 30, 2015

Didn't find any solution to this compilation error, but I was able to install it via brew install memcached

@davidlukac
Copy link

I was building memcache 3.0.8 for PHP 5.6 from Acquia DevDesktop and I was getting error about incorrect architecture (also when I installed memcache via brew). The solution was to add "32bit" flags for the configuration script:

./configure --enable-memcache --with-php-config=/Applications/DevDesktop/php5_6/bin/php-config "CFLAGS=-m32" "CXXFLAGS=-m32" "LDFLAGS=-m32"

The error I was getting was something like wrong architecture in Unknown on line 0 in MAMP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment