我在MediaTemple上安装了新的Ubuntu 11,并将NginX设置为反向代理。 所以静态项由NginX处理,其余的由apache根据这些指令处理:
http://wiki.mediatemple.net/w/(ve):Using_Nginx_as_a_Reverse_Web_Proxy
一切都很好,除非当我重新启动Apache,然后重新启动NginX的最后一步。 Apache重新启动罚款,但是当我重新启动NginX它给了一个关于绑定的错误。 我重新启动服务器,然后尝试重新启动Apache,然后再次NginX。 这一次Apache报告错误,但NginX重新启动罚款。
* Restarting web server apache2 (98)Address already in use: make_sock: could not bind to address 127.0.0.1:80 no listening sockets available, shutting down Unable to open logs Action 'start' failed. The Apache error log may have more information.
Apache日志中的最新错误似乎是:
[Mon Nov 14 06:47:13 2011] [notice] caught SIGTERM, shutting down [Mon Nov 14 06:47:14 2011] [notice] Apache/2.2.17 (Ubuntu) configured -- resuming normal operations [Mon Nov 14 06:47:31 2011] [notice] caught SIGTERM, shutting down
按照说明,我有在Nginx的服务器外部IP和在Apache位置的本地主机IP。
然后我停止NginX重新启动Apache(再次正常工作),然后当重新启动NginX的错误,回来了:
Restarting nginx: [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use) [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use) [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use) [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use) [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use) [emerg]: still could not bind() nginx.
从粘贴的输出中可以清楚的看到, nginx正试图在所有可用IP地址的端口80上进行绑定,而不仅仅是在公共地址上。
您应该仔细查看相关nginxconfiguration文件中的所有listen指令。 你可以通过运行grep -r 'listen ' /etc/nginx/* 。
如果你发现输出看起来像听80; (没有指定IP地址),您应该将其replace为listen xx.xx.xx.xx:80 ,其中xx.xx.xx.xx是您的公共IP地址。
我有几乎相同的问题。 (Ubuntu 10.04,2个真实IP,一个用于Apache,一个用于nginx)。 解决scheme:configuration文件中的每个服务器{…}块都必须具有监听abcd:80指令。 否则nginx会尝试使用所有可用的IP。