看官方文档:
http://httpd.apache.org/docs/2.2/vhosts/name-based.html
示例:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain
</VirtualHost>
<VirtualHost *:80>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>不熟悉的直接在 httpd.conf 结尾贴上上面一段就就好了。
不要问 * 指代什么,它不指代什么, * 就是 *,照着打就是了。
只需要修改 ServerName 为你自己想要的域名,DocumentRoot 为你想设定的 根目录值就好了。
更多的什么 CustomLog ErrorLog,自己照着写吧。

本文介绍如何使用Apache配置基于名称的虚拟主机。通过修改ServerName和DocumentRoot等字段,可以轻松实现不同域名指向不同的网站内容。
796

被折叠的 条评论
为什么被折叠?



