Archive for the ‘memcached’ Category

Installing memcached on OS X 10.7.3 Lion with MAMP or native Apache2 support

Posted on March 15th, 2012 in memcached | 3 Comments »

The post I wrote four years ago on installing memcached on OS X Leopard is still popular today. Here are the updated steps for installing on OS X 10.7.3 Lion with extra steps on getting memcached working with MAMP or your native Apache2.

# memcached requires libevent
cd /tmp
curl -OL https://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 /tmp
curl -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" 
 
# Compile and copy memcached.so module
# For the lazy, you can use my memcached.so file or continue: # curl -O http://readystate4.com/memcache.so
cd /tmp 
# download one and untar http://pecl.php.net/package/memcache
phpize
./configure --enable-memcache
make
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

Installing memcached on OS X 10.5.4 Leopard

Posted on August 19th, 2008 in memcached | 6 Comments »

I used the guide here to install Memcached on my Macbook Pro, but seeing how it was written over 3 years old I decided to write an updated version for installing on OSX Leopard. Here goes:

Beforehand: You need to install Xcode 3.0 Developer Tools. If you don’t have it installed it’s on the Leopard Install CD that came with your Mac. You also have to install the X11 windowing environment on the same disc.

  1. If you don’t have it already, download Macports:
    http://www.macports.org/install.php

    Here’s the Leopard universal binary direct link:
    http://svn.macports.org/repository/macports/downloads/MacPorts-1.6.0/MacPorts-1.6.0-10.5-Leopard.dmg (416kb)

  2. Macports will install itself to /opt/local/bin but on my machine I didn’t have a PATH variable set there so if you type “port” in your terminal and don’t get anything either, continue following this step, else just continue on to the next one.

    Open up terminal and type:

    nano .bash_profile (return key)

    Find the first unused line and type:

    PATH=$PATH:/opt/local/bin

    To save your changes press ctrl-o (return key) and ctrl-x to quit.
    Refresh your profile by typing:

    . .bash_profile
  3. To test that your Macports is working (and to update to the newest version):
    sudo port -v selfupdate
  4. Install libevent. It’s a dependency of memcached:
    sudo port install libevent
  5. Install memcached:
    sudo port install memcached
  6. Set an environment variable to stop libevent using kqueue (should force it to use select, which is slower, but actually works). I have no idea what this does, just following the original guide, but it’s related to making memcached faster :

    Open up terminal and type:

    nano .bash_profile (return key)

    Find the first unused line and type:

    EVENT_NOKQUEUE=yes

    To save your changes press ctrl-o (return key) and ctrl-x to quit.
    Refresh your profile by typing:

    . .bash_profile
  7. Run memcached (this gives it 24MB of memory max, and puts it on port 11211 – note that specifying a hostname will not work on OS X):
    memcached -d -m 24 -p 11211
  8. Telnet to your memcache to make sure it’s working:
    telnet localhost 11211

    If you see “Connected to localhost”, you’re connected.

    Type quit to close the connection and try reconnecting again to make sure you did step 6 properly.

    You’re done!

To stop memcached, type this in your console:

killall memcached

To start memcached in verbose mode (so it outputs what it’s doing) add -vv to the startup script.

Feel free to create a bash script to startup memcached with your right settings, mine looks like this:

#!/usr/bin/env bash

memcached -d -m 24 -p 11211
echo "memcached started..."

Related links:
Installing memcached on OS X 10.4 Tiger
Installing Macports
Memcached homepage

Further reading:
Setup a Memcached-Enabled MAMP Sandbox Environment
Install ruby memcached on MacOSX