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

Apache虚拟主机的配置和泛域名解析实现代码,需要的朋友可以参考下
虚拟主机的配置
  基于IP地址的虚拟主机配置
  Listen 80
  DocumentRoot /www/jb51
  ServerName www.jb51.net
  DocumentRoot /www/jb512
  ServerName www.jb512.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/jb51-80
  ServerName www.jb51.net
  DocumentRoot /www/jb51-8080
  ServerName www.jb51.net
  DocumentRoot /www/example2-80
  ServerName www.jb51.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/jb51
  ServerName www.jb51.net
  ServerAlias jb51.net. *.jb51.net
  # 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/jb51
  ServerName www.jb51.net
  # 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.jb51.net
  DocumentRoot /www/domain-80
  ServerName www.jb51.net
  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/jb51
  ServerName www.jb51.net
  DocumentRoot /www/example2
  ServerName www.example2.org
  DocumentRoot /www/example3
  ServerName www.example3.net
  网站泛域名解析
  添加一个虚拟主机配置(如下):
  
  DocumentRoot d:/web/jb51 # 网站根目录的绝对路径
  ServerName www.jb51.net # 网站域名
  ServerAlias *.jb51.net # 网站泛域名

APACHE泛域名配置参考

NameVirtualHost 192.168.0.110

<VirtualHost 192.168.0.110:80>
DocumentRoot "E:/InterRoot/workplace/"
ServerName www.workplace.com
<Directory "E:/InterRoot/workplace/">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.0.110:80>
DocumentRoot "E:/InterRoot/busymouse_test/"
ServerName www.test.com
<Directory "E:/InterRoot/busymouse_test/">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.0.110:80>
DocumentRoot "E:/InterRoot/iptv_for_browser/auth"
ServerName auth.billing.com
ServerAlias auth.billing.com *.auth.billing.com
#泛域名解析
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"
<Directory "E:/InterRoot/iptv_for_browser/auth">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.0.110:80>
DocumentRoot "E:/InterRoot/iptv_for_browser/api"
ServerName voiz.billing.com
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"
<Directory "E:/InterRoot/iptv_for_browser/api">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.0.110:80>
DocumentRoot "E:/InterRoot/iptv_for_browser/user"
ServerName user.billing.com
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"
<Directory "E:/InterRoot/iptv_for_browser/user">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.0.110:80>
DocumentRoot "E:/InterRoot/iptv_for_browser/center"
ServerName center.billing.com
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"
<Directory "E:/InterRoot/iptv_for_browser/center">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.0.110:80>
DocumentRoot "E:/InterRoot/iptv_for_browser/img"
ServerName img.billing.com
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"
<Directory "E:/InterRoot/iptv_for_browser/img">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.0.110:80>
DocumentRoot "E:/InterRoot/iptv_for_browser/log"
ServerName log.billing.com
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"
<Directory "E:/InterRoot/iptv_for_browser/log">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.0.110:80>
DocumentRoot "E:\InterRoot\billing_new\front"
ServerName admin.billing.com
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"
<Directory "E:\InterRoot\billing_new\front">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

利用nginx泛域名解析配置二级域名和多域名 网站的目录结构为 html ├── bbs └── www html为nginx的安装目录下默认的存放源代码的路径。 bbs为论坛程序源代码路径 www为主页程序源代码路径 把相应程序放入上面的路径通过 http://www.youdomain.com 访问
apache虚拟主机中设置泛域名解析,主要是用到ServerAlias 的配置,供大家学习参考
apache泛域名解析及dns相关,供大家学习参考
泛域名就是我们平常指的二级和三级域名等,这里我们来总结一下Nginx中泛域名解析配置的实例教程,包括正则匹配等细节的讲解,需要的朋友可以参考下
这篇文章主要介绍了Apache实现本地建立泛域名虚拟主机的方法,简单介绍了Apache泛域名虚拟主机的具体创建步骤与相关技巧,需要的朋友可以参考下