Skip to content

Instantly share code, notes, and snippets.

@scottjbarr
Created December 14, 2009 07:26
Show Gist options
  • Save scottjbarr/255875 to your computer and use it in GitHub Desktop.
Save scottjbarr/255875 to your computer and use it in GitHub Desktop.
Install memcached and libevent from source on Debian Etch or Lenny
#!/bin/bash
#
# Download and install libevent and memcached from source on Debian Etch or
# Debian Lenny.
#
# Assumptions
# - libevent and memcached have not been installed from apt repositories
# - memcached is not already running
# - it is ok to clobber scripts at
# /etc/memcached.conf
# /etc/init.d/memcached
# /usr/share/memcached/scripts/start-memcached
#
# Author : Scott Barr
# Date : 14 Dec 2009
#
sudo apt-get install sysv-rc-conf
cd /usr/local/src/
# See http://www.monkey.org/~provos/libevent/ for versions
LIBEVENT_VERSION="libevent-1.4.13-stable"
# See http://memcached.org/ for latest version.
# File is assumed to reside at http://memcached.googlecode.com/files/memcached-${MEMCACHED_VERSION}.tar.gz
MEMCACHED_VERSION="1.4.4"
# where libevent will be installed
LIBEVENT_PREFIX="/opt/${LIBEVENT_VERSION}"
# get the major version of libevent
LIBEVENT_MAJOR_VERSION=`echo $LIBEVENT_VERSION | cut -d\. -f 1,2 | cut -d\- -f 2`
# where memcached will be installed
MEMCACHED_PREFIX="/opt/memcached-${MEMCACHED_VERSION}"
# download, configure and install libevent
wget http://www.monkey.org/~provos/${LIBEVENT_VERSION}.tar.gz
tar -zxf ${LIBEVENT_VERSION}.tar.gz
cd ${LIBEVENT_VERSION}
sudo mkdir /opt/${LIBEVENT_VERSION}
./configure --prefix=${LIBEVENT_PREFIX}
make
sudo make install
sudo ln -s /opt/${LIBEVENT_VERSION}/lib/libevent-${LIBEVENT_MAJOR_VERSION}.so.2 /usr/lib/libevent-${LIBEVENT_MAJOR_VERSION}.so.2
cd ..
# download configure and install memcached
wget http://memcached.googlecode.com/files/memcached-${MEMCACHED_VERSION}.tar.gz
tar -zxf memcached-${MEMCACHED_VERSION}.tar.gz
cd memcached-${MEMCACHED_VERSION}
./configure --prefix=${MEMCACHED_PREFIX} --with-libevent=${LIBEVENT_PREFIX}
make
sudo make install
sudo ln -s /opt/memcached-${MEMCACHED_VERSION}/bin/memcached /usr/local/bin/memcached
cd ..
# download and install memcached config files
wget http://gist.github.com/raw/255825/ecffba4bf23d080d3f472595f62ec9d6e2897769/start-memcached
sudo mkdir -p /usr/share/memcached/scripts
sudo mv start-memcached /usr/share/memcached/scripts/
sudo chmod o+x /usr/share/memcached/scripts/start-memcached
wget http://gist.github.com/raw/255826/54b1694d296c81d71ee89f6358aafd560870563b/memcached
sudo mv memcached /etc/init.d/memcached
sudo chmod o+x /etc/init.d/memcached
wget http://gist.github.com/raw/255828/53e1924d6845d6a90b86a4c5cf3ac81ef9c56af6/memcached.conf
sudo mv memcached.conf /etc/memcached.conf
sudo /etc/init.d/memcached start
sudo sysv-rc-conf --level 2345 memcached on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment