【问题标题】:Setting up Linode (Ubuntu 10.04 32bit) nginx not starting. 98: address already in use设置 Linode (Ubuntu 10.04 32bit) nginx 未启动。 98:地址已被使用
【发布时间】:2013-02-04 19:43:11
【问题描述】:

您好,通过 Ep 的 Railscast 指令设置 linode 时遇到了一点问题。 #335

我对此服务器的配置是:Ubuntu 10.04 LTS Disk Image 32bit

我可以做到这一点:

按预期运行这两项工作。

apt-get -y update

apt-get -y install curl git-core python-software-properties

当我进入 nginx 步骤时:

add-apt-repository ppa:nginx/stable

apt-get -y update

apt-get -y install nginx

到目前为止,一切似乎都正常工作。

在这里:service nginx start

我得到以下回应:

 * 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()

我尝试过停止、重启和重新加载 nginx,但我无法改变任何东西。 任何建议将不胜感激。提前致谢。

【问题讨论】:

    标签: nginx ubuntu-10.04 railscasts linode


    【解决方案1】:

    您似乎有其他东西正在运行或阻止该端口。 尝试运行:sudo netstat -pan | grep ":80"

    这应该给你一个关于那里正在运行的提示。也许它是一个 uwsgi/apache2/tomcat 等。可能在那里运行很多。

    编辑:

    我现在知道问题出在哪里,因为我自己现在在 debian 服务器上遇到了问题。

    listen   80; ## listen for ipv4
    listen   [::]:80 default ipv6only=on; ## listen for ipv6
    

    您应该注释第一行或第二行(取决于您是要收听 ipv6 还是 ipv4。 这就是我遇到的问题。

    【讨论】:

    • 我会尝试的事情:1. sudo service nginx restart 2. 然后尝试重新配置 nginx 以使用其他端口,如果效果很好,您应该深入研究它。 3. sudo netstat -tulpean 的 post 输出
    • 抱歉 Stack Over Flow 打断了我。它返回:udp 0 0 66.xxx.xxx.xxx:xxxxx 80.xxx.xxx.xx:xxx ESTABLISHED xxxx/ntpd
    • 当我使用 ":80" 时什么都没有 当我使用 "80" 我得到上述结果
    • 只是好奇请做一个ps aux | grep nginx
    • root 3472 0.0 0.1 3376 748 pts/0 S+ 18:32 0:00 grep --color=auto nginx
    【解决方案2】:

    我不知道这是否是正确的解决方案,但在我评论该行之后它对我有用:

    listen 80;
    

    在 /etc/nginx/sites-enabled/default 中

    【讨论】: