Nginx无法启动

huangapple go评论84阅读模式
英文:

Nginx won't start

问题

I recently installed Nginx on Ubuntu, and I want to run it, so I use the nginx command, but I got this error.

  1. root@kevin-virtual-machine:/etc/nginx# nginx
  2. nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
  3. nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
  4. nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
  5. nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
  6. nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
  7. nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
  8. nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
  9. nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
  10. nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
  11. nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
  12. nginx: [emerg] still could not bind()
  13. root@kevin-virtual-machine:/etc/nginx#

I haven't done anything; I just installed it and it doesn't work.

I tried searching for the solution, but I haven't found one yet.

英文:

I recently installed Nginx on ubuntu, and I want to run it, so i use the nginx command, but I got this error.

  1. root@kevin-virtual-machine:/etc/nginx# nginx
  2. nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
  3. nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
  4. nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
  5. nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
  6. nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
  7. nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
  8. nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
  9. nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
  10. nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
  11. nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
  12. nginx: [emerg] still could not bind()
  13. root@kevin-virtual-machine:/etc/nginx#

Ii haven't done anything, I just installed it and it doesn't work.

I tried searching for the solution, but I haven't found one yet.

答案1

得分: 1

尝试这些命令:

  1. sudo netstat -tuln | grep :80 # 这是用于查找相同端口上的冲突

重新启动 nginx:

  1. sudo systemctl stop nginx

查找脚本中的错误:

  1. sudo nginx -t

如果以上命令都不起作用,请尝试使用端口 8080 而不是端口 80。

英文:

Try these commands

  1. sudo netstat -tuln | grep :80 # This is for finding confilicts in the same port

Restart nginx

  1. sudo systemctl stop nginx

Find errors in the script :

  1. sudo nginx -t

If none of them worked, try using port 8080 instead of port 80.

答案2

得分: 0

我通过终止Nginx进程来解决了这个问题。以下是我所做的:

  1. 获取每个Nginx进程的进程ID。
  1. pgrep nginx
  1. 然后根据进程ID终止每个进程。
  1. kill [进程ID]
  1. 然后重新启动nginx。
  1. sudo service nginx restart
英文:

I solved it by killing the Nginx processes. Here is what I did:

  1. I get the process ID's of every Nginx process.
  1. pgrep nginx
  1. Then I kill every process, given the process ID
  1. kill [process id]
  1. Then I restarted nginx
  1. sudo service nginx restart

huangapple
  • 本文由 发表于 2023年6月29日 19:08:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/76580480.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定