{"id":2052,"date":"2019-01-13T20:23:12","date_gmt":"2019-01-13T17:23:12","guid":{"rendered":"http:\/\/kifarunix.com\/?p=2052"},"modified":"2019-01-13T22:19:41","modified_gmt":"2019-01-13T19:19:41","slug":"how-to-install-redis-on-ubuntu-18-04-lts","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/how-to-install-redis-on-ubuntu-18-04-lts\/","title":{"rendered":"How to Install Redis on Ubuntu 18.04 LTS"},"content":{"rendered":"<p>This guide presents a simple of how to install Redis on Ubuntu 18.04 LTS. So what is Redis? Redis is a free and open-source in-memory database. It implements different key-value data structures some of them being sets, bitmaps, hashes, lists, strings, streams&#8230;Redis can function as a cache, database or message broker.<\/p>\n<h2>How to Install Redis on Ubuntu 18.04 LTS<\/h2>\n<p>To begin with, re-synchronize your system packages to the latest versions.<\/p>\n<pre>apt update\r\napt upgrade<\/code><\/pre>\n<p>After the package update and upgrade is done, proceed to install Redis on Ubuntu 18.04 LTS server.<\/p>\n<h3>Install Redis on Ubuntu 18.04 LTS<\/h3>\n<p>Installation of Redis on Ubuntu 18.04 is pretty simple since the package is contained on default Ubuntu repositories. Hence, use the package manager to install it as shown below;<\/p>\n<pre>apt install redis-server<\/code><\/pre>\n<p>This command installs Redis server and all the required dependencies on Ubuntu 18.04.<\/p>\n<h4>Configuring Redis on Ubuntu 18.04<\/h4>\n<p>Redis is now installed on Ubuntu 18.04. Before we can Redis as a service, there are a few configuration adjustments that we are going to make in its main configuration file, <code>\/etc\/redis\/redis.conf<\/code>. The adjustment that we are going to make is to define <code>systemd<\/code> as the init system that will manage the Redis service. This can be achieved by changing the line <code>supervised no<\/code> to <code>supervised systemd<\/code>.<\/p>\n<pre>vim \/etc\/redis\/redis.conf<\/code><\/pre>\n<pre>...\r\n# If you run Redis from upstart or systemd, Redis can interact with your\r\n# supervision tree. Options:\r\n#   supervised no      - no supervision interaction\r\n#   supervised upstart - signal upstart by putting Redis into SIGSTOP mode\r\n#   supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET\r\n#   supervised auto    - detect upstart or systemd method based on\r\n#                        UPSTART_JOB or NOTIFY_SOCKET environment variables\r\n# Note: these supervision methods only signal \"process is ready.\"\r\n#       They do not enable continuous liveness pings back to your supervisor.\r\n#supervised no\r\n<strong>supervised systemd\r\n...<\/strong><\/code><\/pre>\n<h3>Restart Redis Server<\/h3>\n<p>When installation completes, Redis server is set to start by default. To clear the doubt, execute the command below to check the Redis server service status.<\/p>\n<pre>systemctl status redis-server<\/code><\/pre>\n<pre><span style=\"color: #00ff00;\">\u25cf<\/span> redis-server.service - Advanced key-value store\r\n   Loaded: loaded (\/lib\/systemd\/system\/redis-server.service; enabled; vendor preset: enabled)\r\n   Active: <span style=\"color: #00ff00;\">active (running)<\/span> since Sun 2019-01-13 16:41:41 EAT; 2min 1s ago\r\n     Docs: http:\/\/redis.io\/documentation,\r\n           man:redis-server(1)\r\n Main PID: 22095 (redis-server)\r\n    Tasks: 4 (limit: 1110)\r\n   CGroup: \/system.slice\/redis-server.service\r\n           \u2514\u250022095 \/usr\/bin\/redis-server 127.0.0.1:6379<\/code><\/pre>\n<p>However, since we have made some configuration changes, be sure to restart it.<\/p>\n<pre>systemctl restart redis-server<\/code><\/pre>\n<p>Redis server is also set to run on system reboot. This can be verified by running the command below;<\/p>\n<pre>systemctl list-unit-files --state=enabled | grep redis-server\r\nredis-server.service                  enabled<\/code><\/pre>\n<h3>Testing Redis Server on Ubuntu 18.04<\/h3>\n<p>So that we can be sure that we have installed Redis server on Ubuntu 18.04 and working fine, you can perform a few simple tests using Redis command line tool called <code>redis-cli<\/code>. Redis server by default listens on TCP port <code>6379<\/code> and loopback address, <code>127.0.0.1<\/code>. As a result, <code>redis-cli<\/code> connect to Redis server via <code>127.0.0.1:6378<\/code>.<\/p>\n<p>To test the connection, we are going to perform the simple ping pong test. See below.<\/p>\n<pre>redis-cli \r\n127.0.0.1:6379&gt; <strong>ping<\/strong>\r\nPONG                 &lt; Response from server\r\n127.0.0.1:6379&gt;<\/code><\/pre>\n<p>This can also be done using a one line command;<\/p>\n<pre>redis-cli -h 127.0.0.1 -p 6379 ping\r\nPONG<\/code><\/pre>\n<p>These few tests have confirmed that our Redis server is working fine. However, if yo need to perform more tests, check <a href=\"https:\/\/redis.io\/topics\/rediscli\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\n<p>This guide has simply taken you through the simple steps of how to install Redis on Ubuntu 18.04 LTS. Thank you for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This guide presents a simple of how to install Redis on Ubuntu 18.04 LTS. So what is Redis? Redis is a free and open-source in-memory<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[299,121],"tags":[300,67],"class_list":["post-2052","post","type-post","status-publish","format-standard","hentry","category-database","category-howtos","tag-redis","tag-ubuntu-18-04","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/2052"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=2052"}],"version-history":[{"count":3,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/2052\/revisions"}],"predecessor-version":[{"id":2055,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/2052\/revisions\/2055"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=2052"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=2052"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=2052"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}