虚拟主机的配置
复制代码代码如下:
Listen 80
DocumentRoot /www/it ServerName www.it.net.cn DocumentRoot /www/it ServerName it.net.cn
基于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/it-80 ServerName www.it.com DocumentRoot /www/it-8080 ServerName www.it.com DocumentRoot /www/example2-80 ServerName www.it.org DocumentRoot /www/example2-8080 ServerName www.example2.org
单个IP地址的服务器上基于域名的虚拟主机配置:
复制代码代码如下:
# Ensure that Apache listens on port 80
Listen 80 # Listen for virtual host requests on all IP addresses NameVirtualHost *:80 DocumentRoot /www/it ServerName www.it.com ServerAlias it.com. *.it.com # Other directives here DocumentRoot /www/example2 ServerName www.example2.org # Other directives here
在多个IP地址的服务器上配置基于域名的虚拟主机:
复制代码代码如下:
Listen 80
# This is the “main” server running on 172.20.30.40 ServerName server.domain.com DocumentRoot /www/mainserver # This is the other address NameVirtualHost 172.20.30.50 DocumentRoot /www/it ServerName www.it.com # Other directives here … DocumentRoot /www/example2 ServerName www.example2.org # Other directives here … 在不同的端口上运行不同的站点:
基于多端口的服务器上配置基于域名的虚拟主机。
复制代码代码如下:
Listen 80
Listen 8080 NameVirtualHost 172.20.30.40:80 NameVirtualHost 172.20.30.40:8080 ServerName www.it.com DocumentRoot /www/domain-80 ServerName www.it.com DocumentRoot /www/domain-8080 ServerName www.example2.org DocumentRoot /www/otherdomain-80 ServerName www.example2.org DocumentRoot /www/otherdomain-8080 基于域名和基于IP的混合虚拟主机的配置:
复制代码代码如下:
Listen 80
NameVirtualHost 172.20.30.40 DocumentRoot /www/it ServerName www.it.com DocumentRoot /www/example2 ServerName www.example2.org DocumentRoot /www/example3 ServerName www.example3.net
网站泛域名解析
复制代码代码如下:
DocumentRoot d:/web/it # 网站根目录的绝对路径
ServerName www.it.com # 网站域名 ServerAlias *.it.com # 网站泛域名
apache泛域名配置参考
复制代码代码如下:
NameVirtualHost 192.168.0.110
<VirtualHost 192.168.0.110:80>
<VirtualHost 192.168.0.110:80>
<VirtualHost 192.168.0.110:80>
<VirtualHost 192.168.0.110:80>
<VirtualHost 192.168.0.110:80>
<VirtualHost 192.168.0.110:80>
<VirtualHost 192.168.0.110:80>
<VirtualHost 192.168.0.110:80>
<VirtualHost 192.168.0.110:80> (责任编辑:IT) |