我已经通过这种方法设置了Apache 2虚拟主机。
下 /etc/apache2/sites-available
我创造了一个 dummy_site_1.conf
dummy_site_1.conf
<VirtualHost local.dummy_site_1:80>
ServerName local.dummy_site_1
ServerAdmin webmaster@localhost
DocumentRoot /var/www/dummy_site_1
ErrorLog /var/log/apache2/dummy_site_1__error.log
TransferLog /var/log/apache2/dummy_site_1__access.log
<Directory /var/www/dummy_site_1>
AllowOverride Options Limit None
Options -Indexes FollowSymLinks
Order deny,allow
Allow from all
</Directory>
DirectoryIndex index.php
#DISABLE HTTP TRACE
#RewriteEngine On
#RewriteCond %{REQUEST_METHOD} ^TRACE
#RewriteRule .* - [F]
</VirtualHost>
我也添加了这一行 httpd.conf
:
ServerName local.dummy_site_1
现在所有人都在使用这个设置,我打字 local.dummy_site_1
在URL中,我可以看到我的网站。
问题是当我尝试添加另一个站点配置时 dummy_site_2.conf
并创建大约相同的设置
dummy_site_2.conf
<VirtualHost local.dummy_site_2:80>
ServerName local.dummy_site_2
ServerAdmin webmaster@localhost
DocumentRoot /var/www/dummy_site_2
ErrorLog /var/log/apache2/dummy_site_2__error.log
TransferLog /var/log/apache2/dummy_site_2__access.log
<Directory /var/www/dummy_site_2>
AllowOverride Options Limit None
Options -Indexes FollowSymLinks
Order deny,allow
Allow from all
</Directory>
DirectoryIndex index.php
#DISABLE HTTP TRACE
#RewriteEngine On
#RewriteCond %{REQUEST_METHOD} ^TRACE
#RewriteRule .* - [F]
</VirtualHost>
我也添加了这一行 httpd.conf
:
ServerName local.dummy_site_2
我收到此错误:
user@host:/etc/apache2$ sudo /etc/init.d/apache2 restart
* Restarting web server apache2 [Wed Sep 15 14:00:43 2010] [error] (EAI 5)No address associated with hostname: Could not resolve host name local.dummy_site_2 -- ignoring!
... waiting [Wed Sep 15 14:00:44 2010] [error] (EAI 5)No address associated with hostname: Could not resolve host name local.dummy_site_2 -- ignoring!
为什么?我配置错了吗?