[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   Cela  阅读(2542)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
· 零经验选手,Compose 一天开发一款小游戏!

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
Copyright ©Cela
Design by Cela
点击右上角即可分享
微信分享提示