有時候在客戶端輸入:nginx
但是終端會輸出以下,顯示啟動失敗
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()
這時候可以輸入:ps -ef| grep nginx
終端會輸出以下,顯示占用的端口
0 551 1 0 9:22PM ?? 0:00.01 nginx: master process nginx -2 614 551 0 9:26PM ?? 0:00.00 nginx: worker process 0 618 606 0 9:27PM ttys000 0:00.00 grep nginx
然后輸入:kill 551
來停止該端口進程。
再在終端輸入:nginx
然后在瀏覽器輸入:http://127.0.0.1:8080/
就會顯示啟動正常。
------------------謝謝大佬們的打賞--------------------