問題描述:
(flaskApi) [root@67 flaskDemo]# service nginx start Redirecting to /bin/systemctl start nginx.service Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
確認問題:html
當不能使用service nginx start 開啓或者使用service nginx stop 關閉時,查看systemctl status nginx 會有必定的錯誤提示nginx
systemctl status nginx -lflask
-l表示:能夠展現所有錯誤信息,不然可能錯誤信息會被摺疊centos
Hint: Some lines were ellipsized, use -l to show in full. post
返回的錯誤提示:url
從這裏咱們能夠看出,是80端口被佔用了centos7
9月 17 14:54:21 67.59.247.60.static.bjtelecom.net nginx[25531]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) spa
經過命令查看80端口被哪一個進程佔用了.net
netstat -tpnul
能夠看到是httpd,這個進程須要是24小時啓動了,不能關掉code
因此接下來的解決辦法有2種
查看nginx的安裝目錄,並找到nginx.conf的目錄:
rpm -ql grep nginx
或者直接使用find命令查找 nginx.conf
(flaskApi) [root@67 flaskDemo]# find / -name nginx.conf
/etc/nginx/nginx.conf
使用nano命令編輯nginx.conf配置文件,圖示中2處默認爲80的端口號改成81
nano /etc/nginx/nginx.conf
另外應當注意:
service nginx start 是centos6.x的命令 , centos7.x使用 systemctl start nginx
再次啓動nginx,沒看到啓動成功的提示信息
(flaskApi) [root@67 flaskDemo]# /bin/systemctl start nginx.service
打印一下當前的進程,能夠看到nginx已經啓動了,而且使用的是81端口
參照文檔:
nginx 在Centos 7 版本的yum安裝 和目錄解釋
nginx啓動報錯的處理辦法,參照:
https://blog.csdn.net/qq_40907977/article/details/91989353