已解决
nginx设置开启自启动
来自网友在路上 155855提问 提问时间:2023-10-25 17:27:17阅读次数: 55
最佳答案 问答题库558位专家为你答疑解惑
nginx安装完成后nginx1.24.0安装,为了保证主机出现异常重启后依然保证能及时提供服务,需要配置开启自启任务。
1、编写nginx.service
vi nginx.service
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network. target remote-fs.target nss -lookup. target[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true[Install]
WantedBy=multi-user.target
usr/local/nginx/目录为nginx的安装目录,根据自己安装nginx目录做调整
将nginx.service移动到/usr/lib/systemd/system/目录下
cp ./nginx.service /usr/lib/systemd/system/
重启配置服务
systemctl daemon-reload
查看nginx服务状态
systemctl status nginx
可见此时nginx服务状态是关闭的
启动nginx.service服务并再次查看状态
systemctl start nginx
systemctl status nginx
配置nginx开机自启
systemctl enable nginx
完成!
查看全文
99%的人还看了
相似问题
猜你感兴趣
版权申明
本文"nginx设置开启自启动":http://eshow365.cn/6-24330-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!