nginx: [alert] kill(5272, 15) failed (3: No such process) 啟動不了,apache搞得鬼


1.啟動

sudo nginx
Password:
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)

2.stop

sudo nginx -s stop
nginx: [alert] kill(5272, 15) failed (3: No such process)

  1. 通過nginx.conf 找 nginx.pid 位置, 然后刪除
cat /usr/local/etc/nginx/nginx.conf | grep .pid
#pid        logs/nginx.pid;

然而找不到
找找找到了....
/usr/local/var/run/nginx.pid
查看下

cat /usr/local/var/run/nginx.pid
5272

與nginx: [alert] kill(5272, 15) failed (3: No such process) 碰頭成功,
刪除該ngix.pid文件,重啟

然而不行

sudo nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)

.......⚠️漫長百度.....

mac默認安裝了apache,隨機啟動會占用80端口,導致nginx啟動不了,需要關閉apache(httpd)服務,取消隨機啟動。

執行命令

查詢80端口被誰占用了
sudo lsof -i:80

 sudo lsof -i:80
COMMAND    PID  USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
httpd       80  root    4u  IPv6 0x1cc38b1a603f3a93      0t0  TCP *:http (LISTEN)
httpd      251  _www    4u  IPv6 0x1cc38b1a603f3a93      0t0  TCP *:http (LISTEN)

關閉隨機啟動

sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

就啟動了

sudo nginx
 jihan@jihandeMacBook-Pro  ~  ps aux | grep nginx
jihan             6842   0.0  0.0  4258648    200 s000  R+   12:58下午   0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox nginx
nobody            6821   0.0  0.0  4295208   1144   ??  S    12:58下午   0:00.00 nginx: worker process
nobody            6820   0.0  0.0  4295208   1144   ??  S    12:58下午   0:00.00 nginx: worker process
nobody            6819   0.0  0.0  4287016   1156   ??  S    12:58下午   0:00.00 nginx: worker process
nobody            6818   0.0  0.0  4295208   1164   ??  S    12:58下午   0:00.00 nginx: worker process
nobody            6816   0.0  0.0  4295208   1156   ??  S    12:58下午   0:00.00 nginx: worker process
nobody            6815   0.0  0.0  4303400   1148   ??  S    12:58下午   0:00.00 nginx: worker process
nobody            6814   0.0  0.0  4295208   1156   ??  S    12:58下午   0:00.00 nginx: worker process
nobody            6813   0.0  0.0  4295208   1144   ??  S    12:58下午   0:00.00 nginx: worker process
root              6812   0.0  0.0  4285528    540   ??  Ss   12:58下午   0:00.00 nginx: master process nginx

相關命令

關閉隨機啟動
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
開啟隨機啟動
sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist
啟動apache

sudo apachectl start
重啟apache

sudo apachectl restart
停止apache

sudo apachectl stop


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM