systemctl操作不了nginx怎么办?

Posted on 2024-04-03 13:51  brad1208  阅读(82)  评论(0编辑  收藏  举报

检查配置:cat /etc/systemd/system/nginx.service

没有的话就创建或编辑配置:vim /etc/systemd/system/nginx.service,注意修改nginx实际配置路径

[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
#ExecReload=/bin/kill -s HUP $MAINPID   ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

 

重新加载 systemd 配置

sudo systemctl daemon-reload

 

尝试重新启动 Nginx 服务

sudo systemctl start nginx.service

 

检查服务状态

sudo systemctl status nginx.service

 

重新加载 Nginx 服务的配置:

sudo systemctl reload nginx