Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Caching Server»How to Install Redis on Ubuntu 18.04 & 16.04 LTS

    How to Install Redis on Ubuntu 18.04 & 16.04 LTS

    By RahulJune 5, 20192 Mins Read

    Redis is an in-memory data structure store, used as a database server, cache, and message broker. Redis is written in C programming language. It also provides a PHP module for communication between PHP script with the Redis server.

    Advertisement

    This tutorial will help you with the installation of Redis server along with PHP Redis PHP extensions on an Ubuntu 19.04, 18.04 LTS, 16.04 LTS and 14.04.

    Step 1 – Prerequsities

    Log in to your system with sudo privilege account using shell access, to which you need to install Redis.

    ssh [email protected]
    

    Update the apt-get packages index files and also update existing packages to the newest versions by using the following commands:

    sudo apt-get update
    sudo apt-get upgrade
    

    Step 2 – Installing Redis

    The Redis packages are available under the default apt repository. For the installation of Redis on an Ubuntu VPS. Run below command from the terminal to install Redis on your machine:

    sudo apt-get install redis-server
    

    Next is to enable Redis to start on system boot. Also restart Redis service once.

    sudo systemctl enable redis-server.service
    

    Step 3 – Configure Redis

    Redis can be started without a configuration file using a built-in default configuration. But to make any extra parameter changes you can use its configuration file that is: /etc/redis/redis.conf. Edit the Redis configuration file in a text editor to make changes

    sudo vim /etc/redis/redis.conf
    

    Update the following values in Redis configuration file according to your requirement. You can increase max memory limit as per available on your server.

    maxmemory 256mb
    maxmemory-policy allkeys-lru
    

    The above configuration tells Redis to remove any key using the LRU algorithm when the max memory of 256mb is reached. Save the configuration file and restart the Redis service:

    sudo systemctl restart redis-server.service
    

    Step 4 – Install Redis PHP Extension

    Now, if you need to use Redis from PHP application, you also need to install Redis PHP extension on your Ubuntu system. Run below command to install:

    sudo apt-get install php-redis
    

    Step 5 – Test Connection to Redis Server

    Use redis-cli tool to verify the connection between the Redis server.

    redis-cli
    
    127.0.0.1:6379> ping
    PONG
    127.0.0.1:6379>
    

    Few more examples of redis-cli command line tool. You can find more details about redis-cli here.

    redis-cli info
    redis-cli info stats
    redis-cli info server
    

    Install Redis on Ubuntu

    redis redis-php
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    How to Install And Configure Redis on Ubuntu & Debian

    How to Change Redis Max Memory

    How to Install Redis on Debian 11 Linux

    How to Install Redis on Debian 11 Linux

    View 11 Comments

    11 Comments

    1. Quiz Dev on February 27, 2021 3:44 am

      Great article, it’s work for me!! Thanks

      Reply
    2. Peter Shearan on July 21, 2020 9:29 am

      Thanks so much Rahul.

      Worked perfectly

      Reply
    3. Mateus on April 28, 2020 10:14 pm

      Thanks for your tutorial it was really useful!!!! Thanks

      Reply
    4. Yilmaz Sarac on January 18, 2020 9:44 pm

      Thank you, this install really clean, it helps,

      Reply
    5. Pedro on September 22, 2019 10:16 pm

      You are just awesome, thank you!

      Reply
    6. sam on August 27, 2019 10:03 pm

      what is the correct way to restart redis-server in ubuntu 18 with another port

      redis-server –port 30000 restart

      Reply
      • Rahul on August 28, 2019 9:11 am

        You can change port (port 6379) in redis.conf file and restart service.

        Reply
    7. devraj on August 20, 2019 12:30 pm

      i’m using angularjs 1.6 ..
      i want to run redis server run in Ubuntu os. so tel me how to do this process

      Reply
    8. Pablo on June 28, 2019 9:11 am

      thanks man ! very clear and clean process…. everything worked fine in Ubuntu 16 LTS

      Reply
    9. Hasan on November 1, 2018 8:56 am

      Hi rahul !

      I’m getting “Failed to start advanced key value store” error ? How can I handle with this ? I try to install redis as your way and also manual but still same error.

      How can I fix this ?

      Reply
      • J on October 2, 2019 11:57 am

        Hi.

        You have to :
        sudo nano /etc/redis/redis.conf
        //open the file and search for “supervised”. It is set to No by default. Change it to “systemd”
        sudo systemctl start redis.service

        Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Implementing a Linux Server Security Audit: Best Practices and Tools
    • cp Command in Linux (Copy Files Like a Pro)
    • 15 Practical Examples of dd Command in Linux
    • dd Command in Linux (Syntax, Options and Use Cases)
    • Iptables: Common Firewall Rules and Commands
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.