Apache虚拟主机的配置和泛域名解析实现代码
<p>虚拟主机的配置<br>
基于IP地址的虚拟主机配置<br>
Listen 80<br>
DocumentRoot /www/zz<br>
ServerName www.zz.net<br>
DocumentRoot /www/zz2<br>
ServerName www.zz2.org<br>
基于IP和多端口的虚拟主机配置<br>
Listen 172.20.30.40:80<br>
Listen 172.20.30.40:8080<br>
Listen 172.20.30.50:80<br>
Listen 172.20.30.50:8080<br>
DocumentRoot /www/zz-80<br>
ServerName www.zz.net<br>
DocumentRoot /www/zz-8080<br>
ServerName www.zz.net<br>
DocumentRoot /www/example2-80<br>
ServerName www.zz.org<br>
DocumentRoot /www/example2-8080<br>
ServerName www.example2.org<br>
单个IP地址的服务器上基于域名的虚拟主机配置:<br>
# Ensure that Apache listens on port 80<br>
Listen 80<br>
# Listen for virtual host requests on all IP addresses<br>
NameVirtualHost *:80<br>
DocumentRoot /www/zz<br>
ServerName www.zz.net<br>
ServerAlias zz.net. *.zz.net<br>
# Other directives here<br>
DocumentRoot /www/example2<br>
ServerName www.example2.org<br>
# Other directives here<br>
在多个IP地址的服务器上配置基于域名的虚拟主机:<br>
Listen 80<br>
# This is the “main” server running on 172.20.30.40<br>
ServerName server.domain.com<br>
DocumentRoot /www/mainserver<br>
# This is the other address<br>
NameVirtualHost 172.20.30.50<br>
DocumentRoot /www/zz<br>
ServerName www.zz.net<br>
# Other directives here …<br>
DocumentRoot /www/example2<br>
ServerName www.example2.org<br>
# Other directives here …<br>
在不同的端口上运行不同的站点:<br>
基于多端口的服务器上配置基于域名的虚拟主机。<br>
Listen 80<br>
Listen 8080<br>
NameVirtualHost 172.20.30.40:80<br>
NameVirtualHost 172.20.30.40:8080<br>
ServerName www.zz.net<br>
DocumentRoot /www/domain-80<br>
ServerName www.zz.net<br>
DocumentRoot /www/domain-8080<br>
ServerName www.example2.org<br>
DocumentRoot /www/otherdomain-80<br>
ServerName www.example2.org<br>
DocumentRoot /www/otherdomain-8080<br>
基于域名和基于IP的混合虚拟主机的配置:<br>
Listen 80<br>
NameVirtualHost 172.20.30.40<br>
DocumentRoot /www/zz<br>
ServerName www.zz.net<br>
DocumentRoot /www/example2<br>
ServerName www.example2.org<br>
DocumentRoot /www/example3<br>
ServerName www.example3.net<br>
网站泛域名解析<br>
添加一个虚拟主机配置(如下):<br>
<br>
DocumentRoot d:/web/zz # 网站根目录的绝对路径<br>
ServerName www.zz.net # 网站域名<br>
ServerAlias *.zz.net # 网站泛域名<br><br><strong>APACHE泛域名配置参考 </strong><br><br>
NameVirtualHost 192.168.0.110<br><br>
<VirtualHost 192.168.0.110:80><br>
DocumentRoot "E:/InterRoot/workplace/"<br>
ServerName www.workplace.com<br>
<Directory "E:/InterRoot/workplace/"><br>
AllowOverride FileInfo<br>
Options Indexes FollowSymLinks Includes<br>
Order allow,deny<br>
Allow from all<br>
</Directory><br>
</VirtualHost><br><br>
<VirtualHost 192.168.0.110:80><br>
DocumentRoot "E:/InterRoot/busymouse_test/"<br>
ServerName www.test.com<br>
<Directory "E:/InterRoot/busymouse_test/"><br>
AllowOverride FileInfo<br>
Options Indexes FollowSymLinks Includes<br>
Order allow,deny<br>
Allow from all<br>
</Directory><br>
</VirtualHost><br><br>
<VirtualHost 192.168.0.110:80><br>
DocumentRoot "E:/InterRoot/iptv_for_browser/auth"<br>
ServerName auth.billing.com<br>
ServerAlias auth.billing.com *.auth.billing.com<br>
#泛域名解析<br>
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"<br>
<Directory "E:/InterRoot/iptv_for_browser/auth"><br>
AllowOverride FileInfo<br>
Options Indexes FollowSymLinks Includes<br>
Order allow,deny<br>
Allow from all<br>
</Directory><br>
</VirtualHost><br><br>
<VirtualHost 192.168.0.110:80><br>
DocumentRoot "E:/InterRoot/iptv_for_browser/api"<br>
ServerName voiz.billing.com<br>
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"<br>
<Directory "E:/InterRoot/iptv_for_browser/api"><br>
AllowOverride FileInfo<br>
Options Indexes FollowSymLinks Includes<br>
Order allow,deny<br>
Allow from all<br>
</Directory><br>
</VirtualHost><br><br>
<VirtualHost 192.168.0.110:80><br>
DocumentRoot "E:/InterRoot/iptv_for_browser/user"<br>
ServerName user.billing.com<br>
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"<br>
<Directory "E:/InterRoot/iptv_for_browser/user"><br>
AllowOverride FileInfo<br>
Options Indexes FollowSymLinks Includes<br>
Order allow,deny<br>
Allow from all<br>
</Directory><br>
</VirtualHost><br><br>
<VirtualHost 192.168.0.110:80><br>
DocumentRoot "E:/InterRoot/iptv_for_browser/center"<br>
ServerName center.billing.com<br>
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"<br>
<Directory "E:/InterRoot/iptv_for_browser/center"><br>
AllowOverride FileInfo<br>
Options Indexes FollowSymLinks Includes<br>
Order allow,deny<br>
Allow from all<br>
</Directory><br>
</VirtualHost><br><br>
<VirtualHost 192.168.0.110:80><br>
DocumentRoot "E:/InterRoot/iptv_for_browser/img"<br>
ServerName img.billing.com<br>
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"<br>
<Directory "E:/InterRoot/iptv_for_browser/img"><br>
AllowOverride FileInfo<br>
Options Indexes FollowSymLinks Includes<br>
Order allow,deny<br>
Allow from all<br>
</Directory><br>
</VirtualHost><br><br>
<VirtualHost 192.168.0.110:80><br>
DocumentRoot "E:/InterRoot/iptv_for_browser/log"<br>
ServerName log.billing.com<br>
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"<br>
<Directory "E:/InterRoot/iptv_for_browser/log"><br>
AllowOverride FileInfo<br>
Options Indexes FollowSymLinks Includes<br>
Order allow,deny<br>
Allow from all<br>
</Directory><br>
</VirtualHost><br><br>
<VirtualHost 192.168.0.110:80><br>
DocumentRoot "E:\InterRoot\billing_new\front"<br>
ServerName admin.billing.com<br>
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"<br>
<Directory "E:\InterRoot\billing_new\front"><br>
AllowOverride FileInfo<br>
Options Indexes FollowSymLinks Includes<br>
Order allow,deny<br>
Allow from all<br>
</Directory><br>
</VirtualHost></p>
頁:
[1]