October 22, 2014

How to build Redis server on Ubuntu 14.04

Recently we used Redis server on Ubuntu 14.04. And I just thought about writing a blog post to show how to build Redis on Ubuntu server or desktop editions. 

First of all you have to go to Redis site and download the redis source code. Redis site

Copy the download link from redis site. Currently download link looks like this "http://download.redis.io/releases/redis-2.8.17.tar.gz". It may change depending on the version you want to download.

Then connect to the server through SSH or take a terminal on Ubuntu desktop machine. Run below command

wget <URL that you copied from redis site>

Then you want to install build-essential and  libjemalloc-dev in order to build redis server. To install those packages run below command.

sudo apt-get update && sudo apt-get install buid-essential libjemalloc-dev

After installing dependencies and tool you want to extract redis archive. Run below commands to extract it. Change the archive name depending on your download.

tar xvf redis-2.X.XX.tar.gz
cd redis-2.X.XX

To build redis server type below command on the terminal. It may take a while to build Redis.

make

If it didn't throw any errors, Congrats! You just build your own Redis server. Then if you want to run Redis server run below command. Make sure that you are in Redis folder.

./src/redis-server

 Then you can test redis server using redis-cli tool like below.

dedunu@test5:~/redis-2.8.17$ src/redis-cli
127.0.0.1:6379>
127.0.0.1:6379> set key1 value1
OK
127.0.0.1:6379> set key2 value15
OK
127.0.0.1:6379> get key1
"value1"
127.0.0.1:6379> get key2
"value15"
127.0.0.1:6379> 

If you get an output like above your redis works fine!

No comments:

Post a Comment