Redis Log

Install Redis on Ubuntu Manually

Estimated reading time: 3 minutes

Installing Redis manually on Ubuntu lets you work with the latest Redis version and gives you full control over the build process. Here’s a step-by-step guide on how to download, build, and install Redis manually on Ubuntu.

Step 1: Preparing Your System

Before downloading Redis, update your system’s package list. This ensures you have the latest dependencies needed for building Redis from source. Run:

The build-essential package includes compilers and libraries needed for Redis, while tcl is required to run the Redis test suite.

Step 2: Downloading Redis

Download Redis directly using wget. In your terminal, run:

This command downloads the latest stable release of Redis as a compressed .tar.gz file.

Step 3: Extracting the Redis Files

Now, extract the downloaded file using:

This creates a directory called redis-stable containing the source files.

Step 4: Building Redis from Source

Next, enter the Redis directory and start the build process:

The make command compiles the Redis source code into executable binaries. Once completed, it’s a good idea to run the Redis test suite to ensure everything is working correctly:

The tests might take a few minutes to complete, and this step verifies that Redis is built correctly.

Step 5: Installing Redis

If the tests pass, install Redis binaries by running:

This command installs Redis binaries in /usr/local/bin, making them available globally on your system.

Step 6: Configuring Redis as a Background Service

To run Redis as a background service, create a configuration directory and copy the Redis configuration file to it:

Now, open the configuration file to modify some settings:

Enable Daemon Mode

Find the daemonize line and set it to yes so Redis runs in the background.

Set Protected Mode

This mode prevents unauthorized access by default and is suitable for production.

Once done, save and exit the editor.

Step 7: Starting Redis Manually after installing

You can now start Redis manually using:

This command launches Redis with the specified configuration file. If you configured it to run as a daemon, Redis will continue running in the background.

Step 8: Setting Up Redis as a System Service

To make Redis start automatically on boot, you can set it up as a systemd service. Create a new service file:

Paste the following into the file:

Save and close the file, then enable and start the Redis service with:

To check the status of Redis, you can use:

Conclusion and Final Thoughts

Installing Redis manually on Ubuntu gives you control over the build and configuration, ensuring you’re using the latest stable version. By following these steps, Redis is now set up to run efficiently as a background service.

Further reading

Leave a Reply

Your email address will not be published. Required fields are marked *