Install Memcached on CentOS 5.1

I can use Yum. But, I am going to install from source in order to get the latest builds.


Memcached requires libevent. So, get and install libevent first.

tar zxpfv libevent*
cd libevent*
sudo make install


Next, install memcached.

tar zxpfv memcached*
cd memcached*
make install

Errors . . . there is always at least one

You may get this error:

error while loading shared libraries: libevent-*: cannot open shared object file: No such file or directory

You need to create a symbolic link. For me, this is the command I needed to run. Yours may differ depending on the release you downloaded.

sudo ln -s /usr/local/lib/ /usr/lib

Start memcached

memcached -d -m 64 -p 11211

"-d" runs memcached in daemon mode.

"-m" is the amount of memory memcached will use in MB's.

"-p" is the port # for memcached.

Connect to it from Rails 2.1

Rails 2.1 is awesome because of its new caching features. It can support memcached as a cache server. In order to get this to work, add/edit the following line in your config/environment.rb file. Or, you can add/edit your specific environments file, such as config/environments.development.rb file.

config.cache_store = :mem_cache_store, 'IP_ADDRESS_OF_MEMCACHED_SERVER:11211'

About this entry


  1. Anonymous January 28, 2009 at 2:30 AM

    Thanks, It helped me :)

  2. Sean Iams February 16, 2009 at 3:01 PM

    Thanks Fred!

    I was getting the "error while loading shared libararies:" error. Creating a symbolic link from /usr/local/lib/ to /usr/lib remedied the problem.

  3. lurchpop August 20, 2009 at 7:26 PM

    symlink worked for me. thanks dude.