背景:今天装了个jpress想弄个博客,然后关了Nginx和uwsgi,启动了tomcat(使用80端口),后来直接shutdown.sh关闭tomcat后,再次启动Nginx报了个错误:
![](https://img-blog.csdnimg.cn/20190303200804921.png)
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
然后使用命令systemctl status nginx.service查看报错详情,输出的是:
![](https://img-blog.csdnimg.cn/20190303200859853.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Z1Y2Fpamlu,size_16,color_FFFFFF,t_70)
nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2019-03-03 19:17:00 CST; 9s ago
Docs: man:nginx(8)
Process: 24254 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=1/FAILURE)
Process: 24838 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Process: 24835 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 15307 (code=killed, signal=KILL)
Mar 03 19:16:58 iZbp1a5bxfhn1xwt8y1yzdZ nginx[24838]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Mar 03 19:16:58 iZbp1a5bxfhn1xwt8y1yzdZ nginx[24838]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Mar 03 19:16:59 iZbp1a5bxfhn1xwt8y1yzdZ nginx[24838]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Mar 03 19:16:59 iZbp1a5bxfhn1xwt8y1yzdZ nginx[24838]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Mar 03 19:17:00 iZbp1a5bxfhn1xwt8y1yzdZ nginx[24838]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Mar 03 19:17:00 iZbp1a5bxfhn1xwt8y1yzdZ nginx[24838]: nginx: [emerg] still could not bind()
Mar 03 19:17:00 iZbp1a5bxfhn1xwt8y1yzdZ systemd[1]: nginx.service: Control process exited, code=exited status=1
Mar 03 19:17:00 iZbp1a5bxfhn1xwt8y1yzdZ systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Mar 03 19:17:00 iZbp1a5bxfhn1xwt8y1yzdZ systemd[1]: nginx.service: Unit entered failed state.
Mar 03 19:17:00 iZbp1a5bxfhn1xwt8y1yzdZ systemd[1]: nginx.service: Failed with result 'exit-code'.
没看出什么特别有价值的信息,根据丰富的踩坑经验,猜测应该是端口有冲突,使用以下命令查看端口使用详情:
netstat -tnlp
显示如下:
![](https://img-blog.csdnimg.cn/20190303201324351.png)
果然是被java占用了,然后使用命令:kill -9 PID关掉占用线程(我这里是kill -9 24531)即可,就可以启动Nginx啦~
如果我的文章对您有帮助,就请客官给个赞吧
![](https://img-blog.csdnimg.cn/20191215233432936.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Z1Y2Fpamlu,size_16,color_FFFFFF,t_70)
![](https://img-blog.csdnimg.cn/20191215233546456.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Z1Y2Fpamlu,size_16,color_FFFFFF,t_70)
![](https://img-blog.csdnimg.cn/20200118181933108.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Z1Y2Fpamlu,size_16,color_FFFFFF,t_70)
THE END!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)