systemctl 管理 nginx
命令:vim /usr/lib/systemd/system/nginx.service
,写入以下内容:
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
根据实际情况修改上述中 nginx 的绝对路径。
systemctl start nginx 卡住问题
确保
/usr/lib/systemd/system/nginx.service
文件中:
PIDFile=/run/nginx.pid
修改 nginx.conf
:
pid /run/nginx.pid;
现在 systemctl start nginx
就不会被卡主了。
————————————————
注:本文转自https://blog.csdn.net/qq_41359051/java/article/details/104419183
Be First to Comment