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.

libevent



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

wget http://monkey.org/~provos/libevent-1.4.6-stable.tar.gz
tar zxpfv libevent*
cd libevent*
./configure
make
sudo make install


memcached



Next, install memcached.

wget http://www.danga.com/memcached/dist/memcached-1.2.6.tar.gz
tar zxpfv memcached*
cd memcached*
./configure
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/libevent-1.4.so.2 /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


3 comments:

  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: libevent-1.3e.so.1" error. Creating a symbolic link from /usr/local/lib/libevent-1.3e.so.1 to /usr/lib remedied the problem.

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

    symlink worked for me. thanks dude.