添加 redis 安装
This commit is contained in:
parent
aa9b672d4f
commit
5d70598113
110
debian11编译redis .md
Normal file
110
debian11编译redis .md
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
### debian 11 安装 编译nginx
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
##### 安装编译环境
|
||||||
|
|
||||||
|
```bash
|
||||||
|
#GCC
|
||||||
|
apt install -y build-essential
|
||||||
|
|
||||||
|
#安装正则库
|
||||||
|
apt install -y libpcre3 libpcre3-dev
|
||||||
|
|
||||||
|
#安装zlib库
|
||||||
|
apt install -y zlib1g-dev
|
||||||
|
|
||||||
|
#openssl
|
||||||
|
apt install -y openssl libssl-dev
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
##### 下载解压源码
|
||||||
|
|
||||||
|
```bash
|
||||||
|
wget https://download.redis.io/redis-stable.tar.gz
|
||||||
|
tar -xzvf redis-stable.tar.gz
|
||||||
|
cd redis-stable
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
##### 编译安装
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make
|
||||||
|
sudo make install
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
##### 修改配置
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 创建配置目录
|
||||||
|
sudo mkdir /etc/redis
|
||||||
|
sudo cp redis.conf /etc/redis/
|
||||||
|
|
||||||
|
# 编辑配置文件
|
||||||
|
sudo vim /etc/redis/redis.conf
|
||||||
|
|
||||||
|
#修改下述配置
|
||||||
|
daemonize yes
|
||||||
|
logfile "/var/log/redis/redis.log"
|
||||||
|
dir /var/lib/redis
|
||||||
|
requirepass your_strong_password_here
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
##### 添加用户
|
||||||
|
|
||||||
|
```bash
|
||||||
|
useradd redis
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
##### 创建进程守护
|
||||||
|
|
||||||
|
```
|
||||||
|
vim /etc/systemd/system/redis.service
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=Redis In-Memory 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
|
||||||
|
Type=forking # 改为 forking
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=5s # 避免频繁重启
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
```
|
||||||
|
|
||||||
|
##### 启动
|
||||||
|
|
||||||
|
```bash
|
||||||
|
systemctl enable redis
|
||||||
|
systemctl restart redis
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
##### 验证安装
|
||||||
|
|
||||||
|
```
|
||||||
|
redis-cli ping
|
||||||
|
```
|
Loading…
x
Reference in New Issue
Block a user