- 新建一个系统服务文件
vim /etc/systemd/system/redis.service • 1
[Unit] Description=redis-server After=network.target [Service] Type=forking # 配置redis的安装目录自定义路径 ExecStart=/usr/local/bin/redis-server /usr/local/src/redis-6.2.6/redis.conf PrivateTmp=true [Install] WantedBy=multi-user.target
- 设置开机自启
# 重载系统服务使配置生效 systemctl daemon-reload # 实现开机自启 systemctl enable redis # 查看redis状态 systemctl status redis