Ubuntu 使用可变子域在Apache2中运行多个网站

Ubuntu 使用可变子域在Apache2中运行多个网站,ubuntu,apache2,Ubuntu,Apache2,我想运行多个网站,我希望每个网站(由子域区分)指向不同的DocumentRoot 我的设置 Host Machine: Mac (Lion) Development Machine Ubuntu 10.04 (a vm using VirtualBox) 从Mac的浏览器中,我希望能够访问 http://website1.dev http://website2.dev 感谢任何能给予的帮助 注意:当我尝试使用服务器名时 apache2: Could not reliably determi

我想运行多个网站,我希望每个网站(由子域区分)指向不同的DocumentRoot

我的设置

Host Machine: Mac (Lion)
Development Machine Ubuntu 10.04 (a vm using VirtualBox)
从Mac的浏览器中,我希望能够访问

http://website1.dev
http://website2.dev
感谢任何能给予的帮助

注意:当我尝试使用服务器名时

 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName

您看过或阅读过最新的在线Apache文档中提供的VirtualHost示例吗?(列表中的第一个)关于“在一个IP地址上运行多个基于名称的网站”应该对您有所帮助,这似乎正是您正在尝试做的。以下是根据您的需要修改的代码片段:

# Ensure that Apache listens on port 80
Listen 80

<VirtualHost *:80>
    DocumentRoot /www/website1
    ServerName website1.dev
    # (Other directives here)
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot /www/website2
    ServerName website2.dev
    # (Other directives here)
</VirtualHost>
#确保Apache侦听端口80
听80
DocumentRoot/www/website1
ServerName网站1.dev
#(此处为其他指令)
DocumentRoot/www/website2
ServerName网站2.dev
#(此处为其他指令)
如果这不起作用,您将不得不详细说明。你的Apache版本是什么?您当前的httpd.conf和virtualhost.conf文件内容是什么