Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Caching Server»How to Install Redis on Ubuntu 20.04

    How to Install Redis on Ubuntu 20.04

    RahulBy RahulMay 10, 20203 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.

    This tutorial will help you to install Redis server along with PHP extensions on an Ubuntu 20.04 LTS system.

    Prerequisites

    Before beginning the Redis server installation on Ubuntu 20.04:

    • Login to Ubuntu as sudo privileged user
    • For the newly installed systems, required to complete initial server setup
    • Step 1 – Install Redis Server

      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 update
      sudo apt install redis-server
      

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

      sudo systemctl enable redis-server
      

      Step 2 – 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
      

      Step 3 – Install PHP Extension (Optional)

      Next, if you need to use Redis with PHP application, you need to install Redis PHP extension on your Ubuntu system. To install Redis PHP extension, type:

      sudo apt install php-redis
      

      The installer will automatically enable redis extension for all the pre installed PHP versions. If you installer new PHP version after this, you can use below command to enable redis module. For example to enable extension for PHP 7.4, type:

      sudo phpenmod -v 7.4 -s ALL redis
      

      Step 4 – Connect to Redis Server

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

      redis-cli
      
      127.0.0.1:6379> ping
      PONG
      
      

      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
      

      Installing redis ubuntu 20.04

      Conclusion

      This tutorial helps you with the installation of Redis server on Ubuntu 20.04 LTS (Focal Fossa) system.

    Cache server database PHP redis redis-cli
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Install Apache with PHP-FPM on Ubuntu 20.04
    Next Article How to Install Roundcube Webmail on CentOS 8

    Related Posts

    How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04

    Updated:May 9, 20223 Mins Read

    How To Install MySQL Server on Ubuntu 22.04

    Updated:April 6, 20224 Mins Read

    How To Install LAMP Stack on Ubuntu 22.04 LTS

    Updated:April 20, 20225 Mins Read

    How To Setup Apache, PHP & MongoDB in Ubuntu & Debian

    Updated:October 8, 20213 Mins Read

    How To Install and Use PHP Composer on Debian 11

    Updated:February 16, 20224 Mins Read

    How To Install MariaDB on Debian 11

    4 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    • (Resolved) Please install all available updates for your release before upgrading
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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