nginx.service配置

有时在nginx安装部署后,service nginx 命令无效,需配置nginx.service使之生效;

vim /usr/lib/systemd/system/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/bin/rm -f $PIDFile 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

wq!保存退出

赋予执行权限

chmod +x /usr/lib/systemd/system/nginx.service

启动服务

systemctl daemon-reload

service nginx start

 

posted @ 2022-10-09 01:00  刀霸汉  阅读(587)  评论(0)    收藏  举报