假设我想在不同的端口上托pipe不同的站点。 服务器的内部IP为192.168.1.108,外部IP为170.24.180.160。 我的路由器转发了170.24.180.160的端口80,81和82。 现在我要在端口80,81和82中分别托pipe站点80,站点81和站点82,所以如果input170.24.180.160:82就会到站点82。
我试过这个:
Listen 80 Listen 81 ... NameVirtualHost 170.24.180.160:80 NameVirtualHost 170.24.180.160:81 ... <VirtualHost 170.24.180.160:80> ServerName site80 DocumentRoot /home/yy/Sites/site80 </VirtualHost> <VirtualHost 170.24.180.160:8080> ServerName site81 DocumentRoot /home/yy/Sites/site81 </VirtualHost> ...
但它给错误:
*Restarting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName [Wed Jun 27 16:10:25 2012] [warn] NameVirtualHost *:80 has no VirtualHosts apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName [Wed Jun 27 16:10:25 2012] [warn] NameVirtualHost *:80 has no VirtualHosts (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80 no listening sockets available, shutting down Unable to open logs Action 'start' failed. The Apache error log may have more information.
我的问题是,基于上述架构,如何设置Apache? 详细的例子是很有帮助的。 谢谢!
你有两个Listen 80指令(这使得Apache试图在端口80上侦听两次),或者你有另外一台web服务器在机器上运行。 检查在端口80上没有其他东西在监听:
netstat -tlnp | grep :80
如果没有显示任何内容,请从您的configuration中删除Listen 80行(它可能已经存在于默认configuration中)。
你也不需要NameVirtualHost,如果你是通过端口来做的话。