- 运行 命令vim /etc/systemd/system/redis.service 输入以下内容
[Unit]
Description=Redis Server
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/redis/redis-5.0.7/src/redis-server /usr/local/redis/redis-5.0.7/redis.conf
User=www #最好不要用root用户 redis漏洞太多 嫌麻烦可以去掉 User Group
Group=www
[Install]
WantedBy=multi-user.target
- sudo systemctl daemon-reload #重载守护程序
- 执行 systemctl enable redis.service #设置开机自启
- 执行 systemctl start redis.service #启动
- 执行 systemctl status redis.service #查看运行状态
- 重启机器