Skip to content

Instantly share code, notes, and snippets.

@torgeir
Forked from lucasmazza/script.md
Last active June 7, 2018 17:44
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save torgeir/1925736 to your computer and use it in GitHub Desktop.
Save torgeir/1925736 to your computer and use it in GitHub Desktop.
Redis 2.4.8 Install on Ubuntu 10.04

Installation commands:

$ wget http://redis.googlecode.com/files/redis-2.4.8.tar.gz
$ tar xvfz redis-2.4.8.tar.gz 
$ cd redis-2.4.8/
$ mkdir -p /opt/redis
$ make PREFIX=/opt/redis install
$ cp redis.conf /opt/redis/redis.conf
$ chown -R redis:redis /opt/redis
$ touch /var/log/redis.log
$ chown redis:redis /var/log/redis.log

Create this upstart script at /etc/init/redis-server.conf:

description "redis server"

start on runlevel [23]
stop on shutdown

exec sudo -u redis /opt/redis/bin/redis-server /opt/redis/redis.conf

respawn

Configure it, here's what I changed:

bind 127.0.0.1
timeout 300
loglevel notice
logfile /var/log/redis.log
dir /opt/redis/

And run it!

$ sudo start redis-server
$ sudo restart redis-server
$ sudo stop redis-server
@nickl-
Copy link

nickl- commented Mar 16, 2012

Thank you for the very concise and detailed instructions, brilliant tutorial.
I can confirm that this also works to install redis 2.4.8 on Ubuntu 11.10 oneiric.

The only possible thing to add to this would be how to create the redis user.
To create a system user, with no shell and therefor no ability to log in, with /opt/redis as its home and a group named redis as primary group:

useradd -rMU -d /opt/redis -s /bin/false -c redis-server redis

Will create the following entry on a new installation at the bottom of /etc/passwd.

redis:x:999:999:redis-server:/opt/redis:/bin/false

Build and install redis 32bit on Ubuntu 64bit installation

Some gotchas when making a 32bit installation on a 64bit stack, which I couldn't find all in one place.
If you don't know why you would want to run redis in 32bit then you probably don't need these steps.

To install the libc6-dev-i386 dependency run:

apt-get install gcc-multilib

To prevent the linker from rejecting the installation add -m32 to the CCLINK value on line 33 of the src/Makefile.

 
vi src/Makefile   
........
CCLINK?=-lm -pthread -m32
........

Take Note: You will have to manually remove the -m32 again if you want to build for 64bit.

Now try the install again and lets see what happens:

make 32bit PREFIX=/opt/redis install

Some further notes:

  • the 32 bit version struggles more with the last few strenuous tests, they will eventually complete successfully.
  • if you still get errors it might be due to partial builds, run make clean and try again before you look elsewhere.
  • if someone has a better fix for linker that will allow both builds to still succeed, please let us know.

Happy sailing...

@torgeir
Copy link
Author

torgeir commented Mar 16, 2012

You're most welcome! I'm glad it came to good use :)

Yes you definitely would want to add your own redis user. I left out the step as I already had an old redis version installed from sudo apt-get install redis, which once again removed leaves the startup scripts and the redis user lying around.

@vancekq
Copy link

vancekq commented Sep 12, 2012

非常感谢,这位朋友,之前我在中国网站找到一些安装方法但都没有成功,用您的方式可以了,Thanks very much :)

@kylefox
Copy link

kylefox commented Apr 10, 2013

This worked excellent for me, thanks for sharing!

One thing worth noting is that you can always get the latest version of Redis from http://download.redis.io/redis-stable.tar.gz. For example: wget http://download.redis.io/redis-stable.tar.gz

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