[Nginx]status:203 Failed to start The NGINX HTTP and reverse proxy server

怎么感觉Linux的nGinx比Win的事一个一个一个的多啊(半恼)

运行systemctl status nginx时提示:

 

① Process: 123456 ExecStartPre=/usr/local/nginx/sbin/nginx -t (code=exited, status=203/EXEC)

这是【nginx.service】里配置绝对路径不匹配的问题:

cp /usr/lib/systemd/system/nginx.service /usr/lib/systemd/system/nginx.service.bak

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=/usr/local/nginx/logs/nginx.pid

ExecStartPre=/usr/local/nginx/sbin/nginx -t

ExecStart=/usr/local/nginx/sbin/nginx

ExecReload=/usr/local/nginx/sbin/nginx -s reload

ExecStop=/bin/kill -s QUIT $MAINPID

ExecStartPost=/bin/sleep 0.1

PrivateTmp=true

[Install]

WantedBy=multi-user.target

更改为nginx的正确路径即可,比如我的是/usr/local/nginx/nginx-1.22.0/,则:

 

 

 

② Process: 123456 ExecStart=/usr/local/nginx/nginx-1.22.0/sbin/nginx (code=exited, status=1/FAILURE)

nginx.conf 文件配置问题,在nginx文件里运行

./nginx -c /usr/local/nginx/nginx-1.22.0/conf/nginx.conf

然后根据报错位置修改即可

 

③ Process: nginx[123456]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

端口被进程占用,kill掉即可

 

先检测是什么进程占用该端口

lsof -i :80

 

 然后根据【PID】执行kill命令即可,比如上图的kill是

kill 159911

再次运行systemctl start nginx&&systemctl status nginx看看状态提示即可

posted on 2022-06-19 15:13  Cela  阅读(2069)  评论(0编辑  收藏  举报

导航

Copyright ©Cela
Design by Cela