1. 程式人生 > >nginx啟動報錯:Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' fo

nginx啟動報錯:Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' fo

class lasso clas blog 80端口 led emc tar 強制

一、背景

這個錯誤在重啟nginx或者啟動nginx的時候,經常會出現。我之前也一直認為出現這個錯誤是因為有程序占用了nginx的進程。但是知其然不知其所以然。每次報錯都有點懵逼,所以這邊一步步排查錯誤,做個記錄。

二、排錯過程

1、按照提示

//按照提示,執行此命令,查看錯誤原因
 systemctl status nginx.service
技術分享圖片

由報錯信息可知,nginx綁定80端口失敗。詳細錯誤請輸入 -l 繼續查看

2、繼續跟蹤錯誤

//查看錯誤的詳情
systemctl status nginx.service -l

這裏輸入 -l 之後,說實話,差距並不大。原因還是綁定端口失敗。

三、解決方案

1、查看此時占用80端口的程序

netstat -ntlp | grep 80
技術分享圖片


這裏可以看到,80端口是被占用的 。我們再詳細看看占用80的是什麽

ps -ef | grep 80

然後找到pid,殺掉這些程序

//-s 9 代表的是快速強制的殺掉pid程序
kill -s 9 pid

2、殺到沒有程序可殺為止,然後啟動nginx

技術分享圖片

此時啟動成功。

轉載自:https://blog.csdn.net/LJFPHP/article/details/79102840

nginx啟動報錯:Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' fo