在Linux上设置虚拟主机

我正在Linux机器上build立一个虚拟主机

我已经做了必要的DNS更改,他们已经传播并正常工作。

在我的/etc/httpd/conf/httpd.conf文件中还有许多其他的虚拟主机正在正常工作(其他人设置了这些主机)。 我的新虚拟主机的configuration是这样的(其中真正的IP已经被replace为##。###。###。###):

<VirtualHost ##.###.###.###:80> ServerName www.website.com ServerAlias website.com DocumentRoot /var/www/html/website.com ErrorLog logs/website.com-error_log CustomLog logs/website.com-access_log combined </VirtualHost> <Directory /var/www/html/website.com> Order deny,allow Allow from all AllowOverride All </Directory> 

该网站的所有文件都位于/var/www/html/website.com。 当我访问website.com时,将显示此服务器上的主站点而不是website.com。

什么是其他configuration设置(任何地方)可以做到这一点? 还有其他的虚拟主机以相同的方式build立(从我可以告诉),他们正在正常工作。

你有ip这样的线路吗?

 # Listen for virtual host requests on IP addresses NameVirtualHost ##.###.#.###:80 

要么

 NameVirtualHost * 

http://httpd.apache.org/docs/2.0/vhosts/examples.html

注意

如果您愿意,可以用系统的实际IP地址replace*。 在这种情况下, VirtualHost的参数必须NameVirtualHost的参数匹配