概要
ローカルでnginxを起動しようとするとタイトルエラーになったので解決方法をメモ
結論
apacheがすでに起動しており、80番portを使っていたため
$ 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)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] still could not bind()
80番portを使用しているプロセスを確認してみると、httpd(apache)を発見
$ sudo lsof -i:80
httpd 77 root 4u IPv6 0xd09cf808e840caf7 0t0 TCP *:http (LISTEN)
httpd 253 _www 4u IPv6 0xd09cf808e840caf7 0t0 TCP *:http (LISTEN)
httpd 638 _www 4u IPv6 0xd09cf808e840caf7 0t0 TCP *:http (LISTEN)
httpd 671 _www 4u IPv6 0xd09cf808e840caf7 0t0 TCP *:http (LISTE
やったこと
apacheのstop
sudo apachectl stop
nginxを起動
sudo nginx
念の為、起動できているか確認
ps -ef | grep nginx
0 24549 1 0 11:33AM ?? 0:00.00 nginx: master process nginx
-2 24550 24549 0 11:33AM ?? 0:00.00 nginx: worker process
無事起動できました!