We will demonstrate the compilation installation of Redis in Ubuntu 16.04.2 LTS (Xenial Xerus). The downloading and building steps are as follows:Â
- Set up building tools:
$ sudo apt-get install build-essential
- Create a directory and enter it for Redis:
$ mkdir /redis
$ cd /redis
- Then, download Redis:
$ wget http://download.redis.io/releases/redis-4.0.1.tar.gz
- Untar it and enter the directory:
$ tar zxvf redis-4.0.1.tar.gz
$ cd redis-4.0.1
- Create a directory for the Redis configuration file and copy the default configuration file into it:
$ mkdir /redis/conf
$ cp redis.conf /redis/conf/
- Building dependencies:
$ cd deps
$ make hiredis lua jemalloc linenoise
$ cd ..
Due to the differences among various operation systems and libraries installed on it, the aforementioned steps will be required when errors occur indicating some dependencies are not satisfied. For example, you may encounter the error message:
zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory.
This step is not a must for most environments, if nothing about dependencies goes wrong.
- Do the compilation:
$ make
If everything goes well, the following message will be shown. It means that the compilation has been done successfully:
It's a good idea to run 'make test' ;)
make[1]: Leaving directory '/redis/redis-4.0.1/src'
- Install Redis:
$ make PREFIX=/redis install
The following messages represent the success of installation:
- Enter the /redis directory and verify that the Redis binary files have been generated:
$ ls /redis/bin
redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server
Congratulations! You have completed the Redis compilation installation.
Compared to the compilation installation, using apt-get in Ubuntu to install Redis is much easier. Let's take a look:
- First, update software repository index:
$ sudo apt-get update
- And then start the installation:
$ sudo apt-get install redis-server
- When it's finished, check if Redis has been set up in your environment:
$ which redis-server