Skip to content

Instantly share code, notes, and snippets.

@linuxdevhub
Last active January 12, 2020 19:25
Show Gist options
  • Save linuxdevhub/8934331fbb2466e3ce22cb0bab092666 to your computer and use it in GitHub Desktop.
Save linuxdevhub/8934331fbb2466e3ce22cb0bab092666 to your computer and use it in GitHub Desktop.
# Youtube: https://youtu.be/EmJbQqhKr58
sudo apt update
sudo apt upgrade
# install the Redis-server package from the official Ubuntu repository
sudo apt install redis-server
# enable Redis to start on system boot. Also restart Redis service once.
sudo systemctl enable redis-server.service
#### Redis Server Basic Configuration ###
# Go to the '/etc/redis' directory and edit the configuration file 'redis.conf' using nano editor.
cd /etc/redis/
sudo nano redis.conf
# Inside the file, find the 'supervised' directive. The supervised directive is set to no by default.
# Since you are running Ubuntu, which uses the systemd init system, change this to systemd. Like this line
# supervised systemd
# Now restart the redis service
systemctl restart redis-server
### Testing Redis ###
# Now make sure there is no error and then check its status.
systemctl status redis-server
# check the default Redis port '6379' using netstat command below.
netstat -plntu
# check the Redis using the 'redis-cli' commands as below.
redis-cli
ping "Hello Redis"
set test "It's working!"
get test
exit
### Binding to localhost ###
# By default, Redis is only accessible from localhost. So, generally you dont need this section.
# To correct this, open the Redis configuration file for editing:
sudo nano /etc/redis/redis.conf
# Locate this line and make sure it is uncommented (remove the # if it exists):
# bind 127.0.0.1 ::1
### Configuring a Redis Password ###
sudo nano /etc/redis/redis.conf
# Scroll to the SECURITY section and look for a commented directive that reads (remove the # if it exists)
# requirepass hakase-labs321@#$
# 'hakase-labs321@#$' is our new redis password here
# save document
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment