{"id":3237,"date":"2020-10-30T19:54:19","date_gmt":"2020-10-30T14:24:19","guid":{"rendered":"https:\/\/www.24x7serversupport.com\/blog\/?p=3237"},"modified":"2023-01-23T17:50:54","modified_gmt":"2023-01-23T12:20:54","slug":"how-to-install-and-configure-redis-on-debian-9","status":"publish","type":"post","link":"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-and-configure-redis-on-debian-9\/","title":{"rendered":"How to Install and Configure Redis on Debian 9"},"content":{"rendered":"\n<p>Redis can be used as a key-value database or also as a cache and message broker. Some of Redis\u2019 features are built-in transactions, replication, and support for a variety of data structures like strings, hashes, lists, sets, and so on. The Redis Sentinel makes Redis highly available and it supports automatic partitioning with Redis Cluster.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.linuxcloudvps.com\/blog\/wp-content\/uploads\/2020\/09\/set-up-install-redis-database-caching-software-on-debian-9-cloud-vps.jpg?w=640&#038;ssl=1\" alt=\"\" class=\"wp-image-1388\" data-recalc-dims=\"1\"\/><\/figure>\n\n\n\n<p>The Redis package which comes with the built in Debian repositories is pretty outdated and contains many vulnerabilities when it comes to security. To fix this in this guide, we are going to use the source version to install Redis. At the moment when this was written, the latest stable version of Redis was 4.0.10. The installation process of Redis on a&nbsp;Debian 9 Cloud VPS&nbsp;is a fairly easy task, but you have to follow the steps carefully as they are given in the tutorial below. Now let\u2019s begin with the installation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Update the OS packages<\/h2>\n\n\n\n<p>Let\u2019s start by upgrading our server to the latest version of all packages. Let\u2019s fetch the latest list of packages, then upgrade our server.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo apt-get update\nsudo apt-get upgrade<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">2. Install dependencies<\/h2>\n\n\n\n<p>If we want to compile from source, the first thing we need to do is to install the build tools:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">apt-get install build-essential tcl wget curl<\/pre>\n\n\n\n<p>You can use the official site to download the Redis source:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">wget http:\/\/download.redis.io\/redis-stable.tar.gz<\/pre>\n\n\n\n<p>Next, the compressed file needs to be extracted to a directory on your server.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cd opt\/\ntar -xvzf redis-stable.tar.gz\ncd redis-stable<\/pre>\n\n\n\n<p>The older Redis versions (up until 4.0) required compiling separate components. But now with version 4, compiling Redis compiles the needed dependencies at the same time, saving us time and reduces the chance of errors.<\/p>\n\n\n\n<p>Compile the source:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">make<\/pre>\n\n\n\n<p>After you have compiled Redis, you then need to install the required binaries onto the server:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">make install<\/pre>\n\n\n\n<p>If you want, you can also test if the Redis binaries and its dependencies have been met by using the command below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">make test<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">3. Starting Redis<\/h2>\n\n\n\n<p>We have downloaded the Redis source package which contains useful utilities that can automate the Redis startup process during system boot.<\/p>\n\n\n\n<p>The next thing on the to-do list is to change into the&nbsp;<code>utils<\/code>&nbsp;directory and execute the build script. The script runs interactively, all you have to do is to accept the default values when prompted.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cd utils\/\n.\/install_server.sh<\/pre>\n\n\n\n<p>The relevant startup scripts which are recommended for the server are installed by the script above. Another thing you need to know is that you can locate the default Redis configuration file at&nbsp;<code>\/etc\/redis.conf<\/code>.<\/p>\n\n\n\n<p>Don\u2019t forget to enable Redis during start up:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl enable redis_6379<\/pre>\n\n\n\n<p>Then you can start Redis like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl start redis_6379<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">4. Configure Redis<\/h2>\n\n\n\n<p>At this point, the Redis development environment needs to be configurated. Therefore, you should first create a directory structure for Redis:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mkdir \/etc\/redis\nmkdir \/var\/www\/redis<\/pre>\n\n\n\n<p>Now, by using the following command you will create a Redis user and group:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">adduser --system --group --no-create-home redis<\/pre>\n\n\n\n<p>Additionally, the Redis group and user ownership should be given to the Redis directory:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">chown redis:redis \/var\/www\/redis\nchmod 770 \/var\/www\/redis<\/pre>\n\n\n\n<p>Then you need to copy the Redis sample configuration file from the Redis source directory to the directory which was created above:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cp redis-stable\/redis.conf \/etc\/redis\/<\/pre>\n\n\n\n<p>As your next step, you should open the Redis configuration file. From there, you can make some changes as per your requirements:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">nano \/etc\/redis\/redis.conf<\/pre>\n\n\n\n<p>Our suggestion is for you to make the following changes:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">port  6379\nsupervised systemd\nlogfile \/var\/log\/redis.log\ndir  \/var\/www\/redis\/\nbind your_server_IP_address<\/pre>\n\n\n\n<p>After you have finished with all of that, you can save and close the file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5. Create a Redis Systemd File<\/h2>\n\n\n\n<p>Furthermore, a system file that will control and manage the Redis daemon should be created.<br>This can be done by creating a&nbsp;<code>redis.service<\/code>&nbsp;file:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">nano \/etc\/systemd\/system\/redis.service<\/pre>\n\n\n\n<p>The following lines need to be added:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[Unit]\nDescription=Redis In-Memory Data Store\nAfter=network.target<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">[Service]\nUser=redis\nGroup=redis\nExecStart=\/usr\/local\/bin\/redis_server \/etc\/redis\/redis.conf\nExecStop=\/usr\/local\/bin\/redis-cli shutdown\nRestart=always<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">[Install]\nWantedBy=multi-user.target<\/pre>\n\n\n\n<p>Once you are done with this, you can save and close the file. Then you can start the Redis service using the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl start redis<\/pre>\n\n\n\n<p>Next thing you need to do is to check the Redis service status and see whether it is running or not:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl status redis<\/pre>\n\n\n\n<p>If you did everything right, you are going to see the following output:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u25cf redis.service - Redis In-Memory Data Store\n   Loaded: loaded (\/etc\/systemd\/system\/redis.service; disabled; vendor preset: enabled)\n   Active: active (running) since Sat 2018-07-28 01:10:03 EDT; 1min 6s ago\n Main PID: 1063 (redis-server)\n    Tasks: 4 (limit: 4915)\n   CGroup: \/system.slice\/redis.service\n           \u2514\u25001063 \/usr\/local\/bin\/redis-server 127.0.0.1:6379\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Redis can be used as a key-value database or also as a cache and message broker. Some of Redis\u2019 features are built-in transactions, replication, and support for a variety of data structures like strings, hashes, lists, sets, and so on. The Redis Sentinel makes Redis highly available and it supports automatic partitioning with Redis Cluster. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3515,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[336,166],"tags":[],"class_list":["post-3237","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-debian","category-ubuntu"],"jetpack_publicize_connections":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Install and Configure Redis on Debian 9 | 24x7serversupport Blog<\/title>\n<meta name=\"description\" content=\"How to Install and Configure Redis on Debian 9. Steps to install Redis on Debian9, How to configure Redis in Debian\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-and-configure-redis-on-debian-9\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Install and Configure Redis on Debian 9 | 24x7serversupport Blog\" \/>\n<meta property=\"og:description\" content=\"How to Install and Configure Redis on Debian 9. Steps to install Redis on Debian9, How to configure Redis in Debian\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-and-configure-redis-on-debian-9\/\" \/>\n<meta property=\"og:site_name\" content=\"24x7serversupport Blog\" \/>\n<meta property=\"article:published_time\" content=\"2020-10-30T14:24:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-23T12:20:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2020\/10\/Redis-Cache-1-1200x720-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"24x7support\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@24x7serversuppo\" \/>\n<meta name=\"twitter:site\" content=\"@24x7serversuppo\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"24x7support\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-and-configure-redis-on-debian-9\/\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-and-configure-redis-on-debian-9\/\",\"name\":\"How to Install and Configure Redis on Debian 9 | 24x7serversupport Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-and-configure-redis-on-debian-9\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-and-configure-redis-on-debian-9\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2020\/10\/Redis-Cache-1-1200x720-1.png?fit=1200%2C720&ssl=1\",\"datePublished\":\"2020-10-30T14:24:19+00:00\",\"dateModified\":\"2023-01-23T12:20:54+00:00\",\"author\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401\"},\"description\":\"How to Install and Configure Redis on Debian 9. Steps to install Redis on Debian9, How to configure Redis in Debian\",\"breadcrumb\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-and-configure-redis-on-debian-9\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-and-configure-redis-on-debian-9\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-and-configure-redis-on-debian-9\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2020\/10\/Redis-Cache-1-1200x720-1.png?fit=1200%2C720&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2020\/10\/Redis-Cache-1-1200x720-1.png?fit=1200%2C720&ssl=1\",\"width\":1200,\"height\":720},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-and-configure-redis-on-debian-9\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.24x7serversupport.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Install and Configure Redis on Debian 9\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#website\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/\",\"name\":\"24x7serversupport Blog\",\"description\":\"Linux | CPanel | WHM | webhosting| Plesk | DirectAdmin | CentOs | Debian | Ubuntu Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.24x7serversupport.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401\",\"name\":\"24x7support\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/author\/24x7support\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Install and Configure Redis on Debian 9 | 24x7serversupport Blog","description":"How to Install and Configure Redis on Debian 9. Steps to install Redis on Debian9, How to configure Redis in Debian","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-and-configure-redis-on-debian-9\/","og_locale":"en_US","og_type":"article","og_title":"How to Install and Configure Redis on Debian 9 | 24x7serversupport Blog","og_description":"How to Install and Configure Redis on Debian 9. Steps to install Redis on Debian9, How to configure Redis in Debian","og_url":"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-and-configure-redis-on-debian-9\/","og_site_name":"24x7serversupport Blog","article_published_time":"2020-10-30T14:24:19+00:00","article_modified_time":"2023-01-23T12:20:54+00:00","og_image":[{"width":1200,"height":720,"url":"https:\/\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2020\/10\/Redis-Cache-1-1200x720-1.png","type":"image\/png"}],"author":"24x7support","twitter_card":"summary_large_image","twitter_creator":"@24x7serversuppo","twitter_site":"@24x7serversuppo","twitter_misc":{"Written by":"24x7support","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-and-configure-redis-on-debian-9\/","url":"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-and-configure-redis-on-debian-9\/","name":"How to Install and Configure Redis on Debian 9 | 24x7serversupport Blog","isPartOf":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-and-configure-redis-on-debian-9\/#primaryimage"},"image":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-and-configure-redis-on-debian-9\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2020\/10\/Redis-Cache-1-1200x720-1.png?fit=1200%2C720&ssl=1","datePublished":"2020-10-30T14:24:19+00:00","dateModified":"2023-01-23T12:20:54+00:00","author":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401"},"description":"How to Install and Configure Redis on Debian 9. Steps to install Redis on Debian9, How to configure Redis in Debian","breadcrumb":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-and-configure-redis-on-debian-9\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.24x7serversupport.com\/blog\/how-to-install-and-configure-redis-on-debian-9\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-and-configure-redis-on-debian-9\/#primaryimage","url":"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2020\/10\/Redis-Cache-1-1200x720-1.png?fit=1200%2C720&ssl=1","contentUrl":"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2020\/10\/Redis-Cache-1-1200x720-1.png?fit=1200%2C720&ssl=1","width":1200,"height":720},{"@type":"BreadcrumbList","@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-and-configure-redis-on-debian-9\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.24x7serversupport.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Install and Configure Redis on Debian 9"}]},{"@type":"WebSite","@id":"https:\/\/www.24x7serversupport.com\/blog\/#website","url":"https:\/\/www.24x7serversupport.com\/blog\/","name":"24x7serversupport Blog","description":"Linux | CPanel | WHM | webhosting| Plesk | DirectAdmin | CentOs | Debian | Ubuntu Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.24x7serversupport.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401","name":"24x7support","url":"https:\/\/www.24x7serversupport.com\/blog\/author\/24x7support\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2020\/10\/Redis-Cache-1-1200x720-1.png?fit=1200%2C720&ssl=1","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/3237","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/comments?post=3237"}],"version-history":[{"count":2,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/3237\/revisions"}],"predecessor-version":[{"id":3247,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/3237\/revisions\/3247"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/media\/3515"}],"wp:attachment":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/media?parent=3237"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/categories?post=3237"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/tags?post=3237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}