突然我得到下面的nginx错误

 * Restarting nginx
 * Stopping nginx nginx
   ...done.
 * Starting nginx nginx
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
   ...done.
   ...done.

如果我跑

lsof -i :80 or sudo fuser -k 80/tcp 

我什么也得不到。80端口上没有东西

然后我运行如下:

sudo netstat -pan | grep ":80"
tcp        0      0 127.0.0.1:8070          0.0.0.0:*               LISTEN      15056/uwsgi     
tcp        0      0 10.170.35.97:39567      10.158.58.13:8080       TIME_WAIT   -               
tcp        0      0 10.170.35.97:39564      10.158.58.13:8080       TIME_WAIT   -               
tcp        0      0 10.170.35.97:39584      10.158.58.13:8080       TIME_WAIT   -               
tcp        0      0 10.170.35.97:39566      10.158.58.13:8080       TIME_WAIT   -               
tcp        0      0 10.170.35.97:39571      10.158.58.13:8080       TIME_WAIT   -               
tcp        0      0 10.170.35.97:39580      10.158.58.13:8080       TIME_WAIT   -               
tcp        0      0 10.170.35.97:39562      10.158.58.13:8080       TIME_WAIT   -               
tcp        0      0 10.170.35.97:39582      10.158.58.13:8080       TIME_WAIT   -               
tcp        0      0 10.170.35.97:39586      10.158.58.13:8080       TIME_WAIT   -               
tcp        0      0 10.170.35.97:39575      10.158.58.13:8080       TIME_WAIT   -               
tcp        0      0 10.170.35.97:39579      10.158.58.13:8080       TIME_WAIT   -               
tcp        0      0 10.170.35.97:39560      10.158.58.13:8080       TIME_WAIT   -               
tcp        0      0 10.170.35.97:39587      10.158.58.13:8080       TIME_WAIT   -               
tcp        0      0 10.170.35.97:39591      10.158.58.13:8080       TIME_WAIT   -               
tcp        0      0 10.170.35.97:39589      10.158.58.13:8080       TIME_WAIT   - 

我被难住了。我如何调试这个?

我在端口8070上使用带有代理通道的uwsgi。Uwsgi正在运行。Nginx则不然。我使用的是ubuntu 12.4

下面是我的nginx conf文件的相关部分

upstream uwsgi_frontend {
          server 127.0.0.1:8070;
        }
server {
listen 80;
        server_name 127.0.0.1;
        location = /favicon.ico {
                  log_not_found off;
                }



                location / {
                       include uwsgi_params;
                       uwsgi_buffering off;

                       uwsgi_pass 127.0.0.1:8070;
                 }
        }

下面是我在ubuntu 12.04上安装nginx的方法

nginx=stable;add-apt-repository ppa:nginx/$nginx;
apt-get update
apt get install nginx-full

当前回答

继续关注@lfender6445和@SAURABH回答——

我的问题还在于,在升级到Vagrant 2.2.2之后,当客户机启动时,Apache2作为web服务器运行。在过去,我只使用nginx作为web服务器。

vagrant ssh进入机箱,并运行以下命令使Apache2在guest机箱引导时不启动:

sudo update-rc.d -f apache2 remove

退出ssh,流浪汉停下来,流浪汉起来。问题解决了。

其他回答

我用nginx运行Varnish服务器。我的varnish服务器运行在端口80上,因此,我的nginx服务器没有启动。我在所有nginx配置文件中将端口更改为8088,但我的default.conf文件在/etc/nginx/conf中。d目录下的Ubuntu服务器。

由于我的conf.d目录包含在主/etc/nginx.conf文件中,nginx没有启动。

将“/etc/nginx/conf.d/default.conf”重命名为“/etc/nginx/conf.d/default.conf”。/etc/nginx/conf.d/*.conf;从我的nginx.conf文件。

我发现了以前从未有过的问题。

我只需要删除/etc/nginx/sites-available/default。然后就成功了。

此删除将只删除符号链接,作为备份,您可以在默认文件中找到 /etc/nginx/sites-enabled /违约

我的conf在/etc/nginx/default

我有几个*。保存文件(紧急转储从nano)从不同的NGINX配置文件在my sites- available目录。一旦我删除了这些.save文件,NGINX重新启动正常。我以为这些是无害的,因为没有相应的符号链接,但我想我错了。

我也有同样的问题,但我看到Nginx监听了80端口:

tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      9730/nginx 

但是当我试图重新启动它时,我有错误:

    service nginx restart
Stopping nginx:                                            [FAILED]
Starting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
nginx: [emerg] still could not bind()

我的问题是在配置文件,我设置PID文件,似乎系统不能正确捕获它:

user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

当我取出它时,它工作了。

问题——我有这个问题。基本上,我所做的就是用正常的nginx命令启动nginx,然后尝试用service nginx reload / restart重新启动nginx,然后我得到这个错误

解决方案-使用nginx -s stop停止nginx,然后重新启动nginx服务器使用服务nginx重启问题解决。