Apache虚拟主机的配置和泛域名解析实现代码

教程大全 2026-01-08 02:46:34 浏览

虚拟主机的配置基于IP地址的虚拟主机配置Listen 80DocumentRoot /www/zzServerName www.zz.NetDocumentRoot /www/zz2ServerName www.zz2.org基于IP和多端口的虚拟主机配置Listen 172.20.30.40:80Listen 172.20.30.40:8080Listen 172.20.30.50:80Listen 172.20.30.50:8080DocumentRoot /www/zz-80ServerName www.zz.netDocumentRoot /www/zz-8080ServerName www.zz.netDocumentRoot /www/example2-80ServerName www.zz.orgDocumentRoot /www/example2-8080ServerName www.example2.org单个IP地址的服务器上基于域名的虚拟主机配置:# Ensure that Apache listens on port 80Listen 80# Listen for Virtual host requests on all IP addressesNameVirtualHost *:80DocumentRoot /www/zzServerName www.zz.netServerAlias zz.net. *.zz.net# Other directives hereDocumentRoot /www/example2ServerName www.example2.org# Other directives here在多个IP地址的服务器上配置基于域名的虚拟主机:Listen 80# This is the “main” server running on 172.20.30.40ServerName server.domain.comDocumentRoot /www/mainserver# This is the other addressNameVirtualHost 172.20.30.50DocumentRoot /www/zzServerName www.zz.net# Other directives here …DocumentRoot /www/example2ServerName www.example2.org# Other directives here …在不同的端口上运行不同的站点:基于多端口的服务器上配置基于域名的虚拟主机。Listen 80Listen 8080NameVirtualHost 172.20.30.40:80NameVirtualHost 172.20.30.40:8080ServerName www.zz.netDocumentRoot /www/domain-80ServerName www.zz.netDocumentRoot /www/domain-8080ServerName www.example2.orgDocumentRoot /www/otherdomain-80ServerName www.example2.orgDocumentRoot /www/otherdomain-8080基于域名和基于IP的混合虚拟主机的配置:Listen 80NameVirtualHost 172.20.30.40DocumentRoot /www/zzServerName www.zz.netDocumentRoot /www/example2ServerName www.example2.orgDocumentRoot /www/example3ServerName www.example3.net网站泛域名解析添加一个虚拟主机配置(如下):DocumentRoot d:/web/zz # 网站根目录的绝对路径ServerName www.zz.net # 网站域名ServerAlias *.zz.net # 网站泛域名 泛域名解析 APACHE泛域名配置参考 NameVirtualHost 192.168.0.110DocumentRoot "E:/InterRoot/workplace/"ServerName www.workplace.comAllowOverride FileInfoOptions Indexes FollowSymLinks IncludesOrder allow,denyAllow from allDocumentRoot "E:/InterRoot/busymouse_test/"ServerName www.test.comAllowOverride FileInfoOptions Indexes FollowSymLinks IncludesOrder allow,denyAllow from allDocumentRoot "E:/InterRoot/iptv_for_browser/auth"ServerName auth.billing.comServerAlias auth.billing.com *.auth.billing.com#泛域名解析ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"AllowOverride FileInfoOptions Indexes FollowSymLinks IncludesOrder allow,denyAllow from allDocumentRoot "E:/InterRoot/iptv_for_browser/api"ServerName voiz.billing.comErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"AllowOverride FileInfoOptions Indexes FollowSymLinks IncludesOrder allow,denyAllow from allDocumentRoot "E:/InterRoot/iptv_for_browser/user"ServerName user.billing.comErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"AllowOverride FileInfoOptions Indexes FollowSymLinks IncludesOrder allow,denyAllow from allDocumentRoot "E:/InterRoot/iptv_for_browser/center"ServerName center.billing.comErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"AllowOverride FileInfoOptions Indexes FollowSymLinks IncludesOrder allow,denyAllow from allDocumentRoot "E:/InterRoot/iptv_for_browser/img"ServerName img.billing.comErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"AllowOverride FileInfoOptions Indexes FollowSymLinks IncludesOrder allow,denyAllow from allDocumentRoot "E:/InterRoot/iptv_for_browser/log"ServerName log.billing.comErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"AllowOverride FileInfoOptions Indexes FollowSymLinks IncludesOrder allow,denyAllow from allDocumentRoot "E:\InterRoot\billing_new\front"ServerName admin.billing.comErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"AllowOverride FileInfoOptions Indexes FollowSymLinks IncludesOrder allow,denyAllow from all

本文版权声明本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,请联系本站客服,一经查实,本站将立刻删除。

发表评论

热门推荐