{"id":16360,"date":"2024-10-31T19:33:52","date_gmt":"2024-10-31T19:33:52","guid":{"rendered":"https:\/\/truehost.com\/support\/?post_type=docs&#038;p=16360"},"modified":"2024-11-02T06:57:41","modified_gmt":"2024-11-02T06:57:41","password":"","slug":"how-to-install-and-configure-redis-on-linux-servers","status":"publish","type":"docs","link":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-install-and-configure-redis-on-linux-servers\/","title":{"rendered":"How to Install and Configure Redis on Linux Servers"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">What is Redis?<\/h3>\n\n\n\n<p>Redis (Remote Dictionary Server) is an open-source, in-memory data structure store that can be used as a database, cache, and message broker. Known for its high performance, Redis supports data structures like strings, hashes, lists, sets, and more. It\u2019s often used for applications requiring fast data retrieval, caching, real-time analytics, and session management.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Prerequisites<\/h3>\n\n\n\n<p>Before installing Redis, ensure that:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>You have a Linux server<\/strong> \u2013 Redis can be installed on distributions like Ubuntu, Debian, CentOS, and RHEL.<\/li>\n\n\n\n<li><strong>Your server is updated<\/strong> \u2013 Run system updates to ensure all packages are current.<\/li>\n\n\n\n<li><strong>Basic command-line knowledge<\/strong> \u2013 Familiarity with Linux commands will be helpful.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Update the Package Repository<\/h3>\n\n\n\n<p>Update your system\u2019s package list to make sure you have access to the latest version of Redis:<\/p>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>For Ubuntu\/Debian<\/strong><\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>For CentOS\/RHEL<\/strong><\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo yum update<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Install Redis<\/h3>\n\n\n\n<p>Redis is available through the default repositories on most Linux distributions, so you can install it directly using your package manager.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>On Ubuntu\/Debian:<\/strong><\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install redis-server -y<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">On CentOS\/RHEL:<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Install EPEL Repository<\/strong> (if not already installed):<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo yum install epel-release -y<\/code><\/pre>\n\n\n\n<p>  2. <strong>Install Redis<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo yum install redis -y<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Configure Redis<\/h3>\n\n\n\n<p>The main configuration file for Redis is usually located at <code>\/etc\/redis\/redis.conf<\/code> on Debian-based systems or <code>\/etc\/redis.conf<\/code> on Red Hat-based systems. Here are some common configurations you may want to adjust:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Enable Persistence<\/strong>: Redis stores data in memory, but you can enable data persistence to save it to disk.<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open the configuration file:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo vi \/etc\/redis\/redis.conf<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Locate the <code>appendonly<\/code> setting and set it to <code>yes<\/code>:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>appendonly yes<\/code><\/pre>\n\n\n\n<p>2. <strong>Set up a Password<\/strong>: For security, set a password to protect your Redis instance.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In the <code>redis.conf<\/code> file, locate <code>requirepass<\/code> and set a strong password:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>requirepass <em>YourStrongPassword<\/em><\/code><\/pre>\n\n\n\n<p>3. <strong>Configure Network Binding<\/strong>: By default, Redis binds to <code>localhost<\/code>. To allow access from other hosts, modify the <code>bind<\/code> setting in the configuration file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>bind 0.0.0.0<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Note<\/strong>: Enabling remote access requires strong security measures, such as firewalls and passwords.<\/li>\n<\/ul>\n\n\n\n<p>4. <strong>Set a Memory Limit<\/strong>: Redis allows you to define a maximum memory usage, which can be helpful if you\u2019re using it as a cache<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Set the memory limit by adding or updating the following lines in the configuration file:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>maxmemory 256mb<br>maxmemory-policy allkeys-lru<\/code><\/pre>\n\n\n\n<p>5. <strong>Define Save Intervals<\/strong>: Redis can periodically save data to disk based on specific intervals.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You can set save intervals in the configuration file like this:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>save 900 1<br>save 300 10<br>save 60 10000<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Start and Enable Redis<\/h3>\n\n\n\n<p>Once configured, start the Redis service and enable it to start at boot:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl start redis\n\nsudo systemctl enable redis<\/code><\/pre>\n\n\n\n<p>To verify that Redis is running:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl status redis<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 5: Testing Redis<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Connect to Redis CLI<\/strong>: Use the Redis CLI to connect to the Redis server.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>redis-cli<\/code><\/pre>\n\n\n\n<p>   2. <strong>Authenticate<\/strong> (if you set a password):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>AUTH YourStrongPassword<\/code><\/pre>\n\n\n\n<p>   3. <strong>Ping the Server<\/strong>: Test the connection by running:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ping<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 6: Enable Redis for External Access (Optional)<\/h3>\n\n\n\n<p>If you plan to access Redis from outside the server (e.g., for use with a web application hosted elsewhere), ensure the Redis port (6379) is open in your firewall:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># For UFW (on Ubuntu)\nsudo ufw allow 6379\n\n# For firewalld (on CentOS\/RHEL)\nsudo firewall-cmd --permanent --add-port=6379\/tcp\nsudo firewall-cmd --reload<\/code><\/pre>\n\n\n\n<p><strong>Warning<\/strong>: Allowing external access to Redis without proper security settings is risky. Always use strong passwords, configure firewalls, or set up a VPN for secure access.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 7: Verify the Installation<\/h3>\n\n\n\n<p>You can access Redis from your local or remote setup by running:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>redis-cli -h -p 6379<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Final Word<\/h3>\n\n\n\n<p>Redis is now installed and configured on your Linux server. You\u2019ve set up basic security, enabled persistence, and adjusted network and memory settings for optimal performance.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is Redis? Redis (Remote Dictionary Server) is an open-source, in-memory data structure store that can be used as a database, cache, and message broker. Known for its high performance, Redis supports data structures like strings, hashes, lists, sets, and more. It\u2019s often used for applications requiring fast data retrieval, caching, real-time analytics, and session [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_eb_attr":"","_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"doc_category":[1820,1824,1879,2128],"doc_tag":[],"class_list":["post-16360","docs","type-docs","status-publish","hentry","doc_category-cloud-servers-in-kenya","doc_category-dedicated-servers","doc_category-servers","doc_category-vps-servers"],"year_month":"2026-07","word_count":606,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"Eugene","author_nicename":"eugene","author_url":"https:\/\/truehost.com\/support\/author\/eugene\/"},"doc_category_info":[{"term_name":"Cloud servers in Kenya","term_url":"https:\/\/truehost.com\/support\/docs-category\/cloud-servers-in-kenya\/"},{"term_name":"dedicated servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/dedicated-servers\/"},{"term_name":"Servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/servers\/"},{"term_name":"VPS-Servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/vps-servers\/"}],"doc_tag_info":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Install and Configure Redis on Linux Servers -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-install-and-configure-redis-on-linux-servers\/\" \/>\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 Linux Servers -\" \/>\n<meta property=\"og:description\" content=\"What is Redis? Redis (Remote Dictionary Server) is an open-source, in-memory data structure store that can be used as a database, cache, and message broker. Known for its high performance, Redis supports data structures like strings, hashes, lists, sets, and more. It\u2019s often used for applications requiring fast data retrieval, caching, real-time analytics, and session [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-install-and-configure-redis-on-linux-servers\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-02T06:57:41+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-install-and-configure-redis-on-linux-servers\\\/\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-install-and-configure-redis-on-linux-servers\\\/\",\"name\":\"How to Install and Configure Redis on Linux Servers -\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#website\"},\"datePublished\":\"2024-10-31T19:33:52+00:00\",\"dateModified\":\"2024-11-02T06:57:41+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-install-and-configure-redis-on-linux-servers\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-install-and-configure-redis-on-linux-servers\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-install-and-configure-redis-on-linux-servers\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/truehost.com\\\/support\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Install and Configure Redis on Linux Servers\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#website\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/\",\"name\":\"\",\"description\":\"Help In a Click\",\"publisher\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/truehost.com\\\/support\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#organization\",\"name\":\"Truehost Kenya\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"contentUrl\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"width\":240,\"height\":48,\"caption\":\"Truehost Kenya\"},\"image\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Install and Configure Redis on Linux Servers -","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:\/\/truehost.com\/support\/knowledge-base\/how-to-install-and-configure-redis-on-linux-servers\/","og_locale":"en_US","og_type":"article","og_title":"How to Install and Configure Redis on Linux Servers -","og_description":"What is Redis? Redis (Remote Dictionary Server) is an open-source, in-memory data structure store that can be used as a database, cache, and message broker. Known for its high performance, Redis supports data structures like strings, hashes, lists, sets, and more. It\u2019s often used for applications requiring fast data retrieval, caching, real-time analytics, and session [&hellip;]","og_url":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-install-and-configure-redis-on-linux-servers\/","article_modified_time":"2024-11-02T06:57:41+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-install-and-configure-redis-on-linux-servers\/","url":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-install-and-configure-redis-on-linux-servers\/","name":"How to Install and Configure Redis on Linux Servers -","isPartOf":{"@id":"https:\/\/truehost.com\/support\/#website"},"datePublished":"2024-10-31T19:33:52+00:00","dateModified":"2024-11-02T06:57:41+00:00","breadcrumb":{"@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-install-and-configure-redis-on-linux-servers\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/truehost.com\/support\/knowledge-base\/how-to-install-and-configure-redis-on-linux-servers\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-install-and-configure-redis-on-linux-servers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/truehost.com\/support\/"},{"@type":"ListItem","position":2,"name":"How to Install and Configure Redis on Linux Servers"}]},{"@type":"WebSite","@id":"https:\/\/truehost.com\/support\/#website","url":"https:\/\/truehost.com\/support\/","name":"","description":"Help In a Click","publisher":{"@id":"https:\/\/truehost.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/truehost.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/truehost.com\/support\/#organization","name":"Truehost Kenya","url":"https:\/\/truehost.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/truehost.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","contentUrl":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","width":240,"height":48,"caption":"Truehost Kenya"},"image":{"@id":"https:\/\/truehost.com\/support\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/16360","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/comments?post=16360"}],"version-history":[{"count":2,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/16360\/revisions"}],"predecessor-version":[{"id":16558,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/16360\/revisions\/16558"}],"wp:attachment":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/media?parent=16360"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/doc_category?post=16360"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/doc_tag?post=16360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}