Skip to content

Instantly share code, notes, and snippets.

@pterk
Last active September 26, 2018 15:42
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save pterk/3923177 to your computer and use it in GitHub Desktop.
Save pterk/3923177 to your computer and use it in GitHub Desktop.
install redis in a virtualenv
#!/bin/bash
VERSION="2.8.5"
ARCHIVE=redis-${VERSION}.tar.gz
if [ -z "${VIRTUAL_ENV}" ]; then
echo "Please activate a virtualenv first";
exit
fi
pushd /tmp/
if [ ! -f redis-${VERSION}.tar.gz ]
then
wget http://download.redis.io/releases/${ARCHIVE}
fi
DIRNAME=`tar tzf ${ARCHIVE} 2>/dev/null | head -n 1`
tar xzf ${ARCHIVE}
pushd ${DIRNAME}
# make / make install w/ prefix
make PREFIX=${VIRTUAL_ENV}
make PREFIX=${VIRTUAL_ENV} install
mkdir -p ${VIRTUAL_ENV}/etc/
mkdir -p ${VIRTUAL_ENV}/run/
mkdir -p ${VIRTUAL_ENV}/etc/
mkdir -p ${VIRTUAL_ENV}/run/
sed -i 's/daemonize no/daemonize yes/' redis.conf
# prepare VIRTUAL_ENV-path for sed (escape / with \/)
VIRTUAL_ENV_ESC="${VIRTUAL_ENV//\//\\/}"
sed -i "s/\/var\/run/${VIRTUAL_ENV_ESC}\/run/" redis.conf
sed -i "s/dir \.\//dir ${VIRTUAL_ENV_ESC}\/run\//" redis.conf
cp redis.conf ${VIRTUAL_ENV}/etc/
popd
popd
@mickhan
Copy link

mickhan commented Jan 31, 2013

very useful!

@mehdisadeghi
Copy link

Time saving, thanks.

@melerz
Copy link

melerz commented May 20, 2015

Thank you very much, very helpful :)

@MalFan
Copy link

MalFan commented May 13, 2017

Very helpful. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment