Nginx无法绑定错误

时间:2018-06-09 15:07:55

标签: nginx centos

每当我尝试访问我的网站时,即运行Nginx,此错误消息会显示在日志中:

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 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 [::]:80 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 [::]:80 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 [::]:80 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 [::]:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()

我环顾四周,大多数人要说的是杀死nginx服务并重新启动它,以及使用该端口的任何其他服务,这可能是问题的原因。当我运行netstat命令时,显示的是:

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      3997/nginx: master
tcp6       0      0 :::80                   :::*                    LISTEN      3997/nginx: master

然后,我用以下方法杀死任务:

sudo fuser -k 80/tcp

我再次运行netstat以确保没有运行,什么都没有。然后我继续重新启动nginx,发现它仍然有这个错误。这是我的nginx配置文件:

server 
{
    listen         80 default_server;
    listen         [::]:80 default_server;
    server_name    example.com www.example.com;
    root           /var/www/html;
    index          index.html;

    location ~* \.php$ 
    {
        fastcgi_pass    127.0.0.1:9000;
        include         fastcgi_params;
        fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
        fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
    }
}

我还尝试将ipv6 = on或类似标签添加到底部监听端口,但这并没有影响任何内容。如果有人知道我做错了什么,将不胜感激。

0 个答案:

没有答案