forked from Genaker/Magento-Linux-Installation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-redis-compile.sh
109 lines (73 loc) · 2.08 KB
/
install-redis-compile.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
# Tested Centos 8, AWS, ARM
echo "Install Redis"
# You can cahnge version. List is here : https://download.redis.io/releases/
REDIS_VERSION='redis-stable'
yum install wget make -y
sudo yum install gcc -y
exists()
{
command -v "$1" >/dev/null 2>&1
}
if exists Redis; then
echo 'Redis exists!'
else
wget "http://download.redis.io/$REDIS_VERSION.tar.gz"
tar xvzf $REDIS_VERSION.tar.gz
rm $REDIS_VERSION.tar.gz
cd ./$REDIS_VERSION/deps
make hiredis jemalloc linenoise lua geohash-int
cd ..
make
sudo make install
sudo mkdir -p /etc/redis
cd ..
pwd
sudo cp ./$REDIS_VERSION/redis.conf /etc/redis
sudo groupadd redis
sudo adduser --system -g redis --no-create-home redis
mkdir -p /var/lib/redis
# Use gpasswd for immediate change
sudo gpasswd -a redis redis
#ToDo: Improve permissions
#sudo chmod -R 777 /usr/local/bin/redis-server /etc/redis/redis.conf
#sudo -u ec2-user /usr/local/bin/redis-server --daemonize yes
# Run as SUDO
# Detailed instruction: https://www.digitalocean.com/community/tutorials/how-to-install-redis-from-source-on-ubuntu-18-04
cat > /etc/systemd/system/redis.service <<END
[Unit]
Description=Redis Data Store
After=network.target
[Service]
User=redis
Group=redis
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always
[Install]
WantedBy=multi-user.target
END
cd ..
# save ""
# Disable save on disc
sed -i 's/# save ""/save ""/g' /etc/redis/redis.conf
#auto start Redis after searver reload
set +e
sudo systemctl enable redis
sudo systemctl start redis
sudo service redis status --no-pager
rm -rf ./$REDIS_VERSION
rm -rf ./redis-stable/
set -e
fi
# It is also possible to remove all the previously configured save
# points by adding a save directive with a single empty string argument
# like in the following example:
#
# save ""
#/etc/redis/redis.conf
# bind 0.0.0.0
# Set the number of databases. The default database is DB 0, you can select
# a different one on a per-connection basis using SELECT <dbid> where
# dbid is a number between 0 and 'databases'-1
# databases 1000000