虚拟主机的配置
基于IP地址的虚拟主机配置
Listen 80
DocumentRoot /www/*******
ServerName www.hacker.com.cn
DocumentRoot /www/*******
ServerName www.*******.org
基于IP和多端口的虚拟主机配置
Listen 172.20.30.40:80
Listen 172.20.30.40:8080
Listen 172.20.30.50:80
Listen 172.20.30.50:8080
DocumentRoot /www/*******-80
ServerName www.hacker.com.cn
DocumentRoot /www/*******-8080
ServerName www.hacker.com.cn
DocumentRoot /www/*******-80
ServerName www.*******.org
DocumentRoot /www/*******-8080
ServerName www.*******.org
# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
DocumentRoot /www/*******
ServerName www.hacker.com.cn
ServerAlias *******.com. *.*******.com
# Other directives here
DocumentRoot /www/*******
ServerName www.*******.org
# Other directives here
Listen 80
# This is the “main” server running on 172.20.30.40
ServerName server.*******.com
DocumentRoot /www/mainserver
# This is the other address
NameVirtualHost 172.20.30.50
DocumentRoot /www/*******
ServerName www.hacker.com.cn
# Other directives here …
DocumentRoot /www/*******
ServerName www.*******.org
# Other directives here …
在不同的端口上运行不同的站点:
Listen 80
Listen 8080
NameVirtualHost 172.20.30.40:80
NameVirtualHost 172.20.30.40:8080
ServerName www.hacker.com.cn
DocumentRoot /www/*******-80
ServerName www.hacker.com.cn
DocumentRoot /www/*******-8080
ServerName www.*******.org
DocumentRoot /www/other*******-80
ServerName www.*******.org
DocumentRoot /www/other*******-8080
基于域名和基于IP的混合虚拟主机的配置:
Listen 80
NameVirtualHost 172.20.30.40
DocumentRoot /www/*******
ServerName www.hacker.com.cn
DocumentRoot /www/*******
ServerName www.*******.org
DocumentRoot /www/*******
ServerName www.*******.net
网站泛域名解析
添加一个虚拟主机配置(如下):
DocumentRoot d:/web/******* # 网站根目录的绝对路径
ServerName www.rongsen.com.cn # 网站域名
ServerAlias *.*******.cn # 网站泛域名