启动 nginx 就会报错,提示80端口被占用
nginx: [emerg] bind() to 0.0.0.0:8080 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8080 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8080 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8080 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8080 failed (48: Address already in use)
nginx: [emerg] still could not bind()
试了无数种方法,找进程,kill进程,网络监视器找进程,都没有成功。
最终解决办法
lsof -iTCP -sTCP:LISTEN -P | grep :80
找到哪个进程监听的 80 端口
没有 lsof 的话先安装lsof
brew install lsof
最后kill 进程
sudo kill PID