Installing memcached on OS X 10.5.4 Leopard
Posted on August 19th, 2008 in memcached | 2 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.
- If you don’t have it already, download Macports:
http://www.macports.org/install.phpHere’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) - Macports will install itself to
/opt/local/binbut 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) andctrl-xto quit.
Refresh your profile by typing:. .bash_profile
- To test that your Macports is working (and to update to the newest version):
sudo port -v selfupdate
- Install libevent. It’s a dependency of memcached:
sudo port install libevent
- Install memcached:
sudo port install memcached
- 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) andctrl-xto quit.
Refresh your profile by typing:. .bash_profile
- 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
- Telnet to your memcache to make sure it’s working:
telnet localhost 11211
If you see “Connected to localhost”, you’re connected.
Type
quitto 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