Nginx无法启动

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

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.

root@kevin-virtual-machine:/etc/nginx# nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
nginx: [emerg] still could not bind()
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.

root@kevin-virtual-machine:/etc/nginx# nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
nginx: [emerg] still could not bind()
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

尝试这些命令:

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

重新启动 nginx:

sudo systemctl stop nginx

查找脚本中的错误:

sudo nginx -t

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

英文:

Try these commands

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

Restart nginx

sudo systemctl stop nginx

Find errors in the script :

sudo nginx -t

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

答案2

得分: 0

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

  1. 获取每个Nginx进程的进程ID。
     pgrep nginx
  1. 然后根据进程ID终止每个进程。
     kill [进程ID]
  1. 然后重新启动nginx。
    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.
     pgrep nginx
  1. Then I kill every process, given the process ID
     kill [process id]
  1. Then I restarted nginx
    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:

确定