Skip to content

Instantly share code, notes, and snippets.

@rogerlin0330
Forked from FUT/install-redis.sh
Last active April 30, 2021 21:27
Show Gist options
  • Save rogerlin0330/b50a681cba85ce66a60d362469c93c67 to your computer and use it in GitHub Desktop.
Save rogerlin0330/b50a681cba85ce66a60d362469c93c67 to your computer and use it in GitHub Desktop.
Install Redis on EC2
1. Install Linux updates, followed by GCC and Make
sudo yum update
sudo yum install gcc make
sudo yum install tcl
2. Download, Untar and Make Redis 6.2.2 (check here http://redis.io/download)
cd /tmp
wget https://download.redis.io/releases/redis-6.2.2.tar.gz
tar -zxf redis-6.2.2.tar.gz
cd redis-6.2.2
sudo make
sudo make test
sudo make install
3. Create Groups and Users
sudo groupadd redis
sudo gpasswd redis
sudo useradd -g redis -M -s /bin/false redis
4. Create Directories and Copy the Redis Configuration File
sudo mkdir /etc/redis
sudo mkdir /var/lib/redis
sudo cp redis.conf /etc/redis/redis.conf
sudo chown -R redis:redis /etc/redis
sudo chown -R redis:redis /var/lib/redis
4. Configure Redis.Conf
sudo vim /etc/redis/redis.conf
[..]
daemonize yes
[..]
[..]
bind 127.0.0.1
[..]
[..]
dir /var/lib/redis
[..]
[..]
requirepass <password>
5. Settup Systemd Service
Put the following into /etc/systemd/system/redis.service:
[Unit]
Description=Redis
After=syslog.target network-online.target
Wants=network-online.target
[Service]
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
Restart=on-failure
User=redis
Group=redis
[Install]
WantedBy=multi-user.target
8. Enable and Start Redis Server
sudo systemctl enable redis.service
sudo systemctl start redis.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment