Tuesday, June 18, 2024

Install Redis Server on Ubuntu

Assalamu Alaikum.
Welcome to Uddoyon, in this article we try to know How to Install Redis Server & Redis-PHP on Ubuntu System so keep reading…

Redis is an open-source, High-Performance, in-memory key-value store that is widely used for caching and data storage. In this guide, we will walk you through the process of installing Redis Server and the php-redis extension on an Ubuntu system. By the end of this tutorial, you’ll have a fully functional Redis Server and the ability to interact with it using PHP.

- Advertisement -


  • A Ubuntu system (tested on Ubuntu 22.04 LTS).
  • Access to a terminal with sudo privileges.
  • Basic familiarity with the Linux command line.

Step 1 – Update System Packages:
Start by ensuring your system’s package repositories are up-to-date:

- Advertisement -
sudo apt update
sudo apt upgrade

Step 2 – Install Redis Server:
Install Redis Server from the official Ubuntu repositories:

sudo apt install redis-server

Step 3 – Configure Redis:
The default Redis configuration is usually sufficient for most use cases. However, you can adjust settings in the configuration file located at “/etc/redis/redis.conf”.

- Advertisement -

Step 4 – Start and Enable Redis Service:
Start the Redis service and enable it to start on boot:

sudo systemctl start redis-server
sudo systemctl enable redis-server

Step 5 – Test Redis Server:
Test if Redis is running by connecting to it using the Redis CLI:


You should see a Redis prompt. You can test basic commands like ‘PING’ and ‘SET key value’.

Step 6 – Install php-redis Extension:
Install the php-redis extension to enable Redis support in PHP:

sudo apt install php-redis

Step 7 – Restart PHP-FPM and Test php-redis:
Restart PHP-FPM to load the new extension:

sudo systemctl restart php-fpm

Create a PHP test file to verify the php-redis extension is working:

echo "<?php
$redis = new Redis();
$redis->connect('', 6379);
echo 'Connection to server successful!';
?>" | sudo tee /var/www/html/redis-test.php

Access the test page by navigating to ‘http://localhost/redis-test.php‘ in your web browser.

Step 8 – Interact with Redis Using PHP:
You can now use the ‘php-redis’ extension in your PHP code to interact with the Redis Server. Examples include caching, session management, and more.

Congratulations! You’ve successfully installed Redis Server and the php-redis extension on your Ubuntu system. Redis provides a powerful and efficient caching and data storage solution, while php-redis allows you to seamlessly integrate Redis functionality into your PHP applications. You’re now equipped to leverage the benefits of Redis in your projects to enhance performance and scalability.

Thanks for Reading, stay with us to know more things as like this.

- Advertisement -
- Advertisement -
Related Articles
- Advertisement -

Popular Articles

- Advertisement -
error: Content is protected !!