虚拟主机的配置
基于IP地址的虚拟主机配置
Listen 80
DocumentRoot /www/zz
ServerName www.zz.net
DocumentRoot /www/zz2
ServerName www.zz2.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/zz-80
ServerName www.zz.net
DocumentRoot /www/zz-8080
ServerName www.zz.net
DocumentRoot /www/example2-80
ServerName www.zz.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/zz
ServerName www.zz.net
ServerAlias zz.net. *.zz.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/zz
ServerName www.zz.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.zz.net
DocumentRoot /www/domain-80
ServerName www.zz.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/zz
ServerName www.zz.net
DocumentRoot /www/example2
ServerName www.example2.org
DocumentRoot /www/example3
ServerName www.example3.net
网站泛域名解析
添加一个虚拟主机配置(如下):
DocumentRoot d:/web/zz # 网站根目录的绝对路径
ServerName www.zz.net # 网站域名
ServerAlias *.zz.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>
Apache虚拟主机的配置和泛域名解析实现代码
2021-04-12 01:40主机之家 虚拟主机
Apache虚拟主机的配置和泛域名解析实现代码,需要的朋友可以参考下
延伸 · 阅读
- 2022-03-10Apache访问日志的配置与使用
- 2022-03-10使用Apache commons-cli包进行命令行参数解析的示例
- 2022-03-09Ubuntu 16.04与Apache虚拟主机配置的步骤详解
- 2022-03-06Ubuntu14.04服务器环境下配置PHP7.0+Apache2+Mysql5.7的方
- 2022-03-06CentOS 7中 Apache Web 服务器安装配置教程
- 2022-03-03APACHE服务器出现No input file specified.的完美解决方
- 虚拟主机
怎么选择香港空间?香港空间哪家好?
随着国家政策、备案审查的越来越严格。现在许多站长朋友都特别喜欢使用香港空间。因为香港空间的话,不需要备案、网络质量方面和国内空间相差不大...
- 虚拟主机
Windows虚拟主机禁用脚本执行权限方法
如果您使用的是Windows虚拟主机,需要禁止某个目录的脚本执行权限,您可以在要禁用脚本执行权限的目录建立一个web.config文件,里面加入下面的代码: ...
- 虚拟主机
100m的虚拟主机可以做什么
100m的虚拟主机可以做什么?100m的虚拟主机可以做个人博客、数据较少的中小企业官网、数据共享平台、软件应用平台等...
- 虚拟主机
虚拟主机流量会受到什么限制?
网站的访问情况越来越卡了,有可能是你对虚拟主机流量受到限制了。虚拟主机的流量也会受到限制吗?这种情况当然是可能的,虚拟主机流量指的是用户在...
- 虚拟主机
浅谈Arvixe VPS的支付宝购买及香港数据中心使用体验
这篇文章主要介绍了Arvixe VPS的支付宝购买及香港数据中心使用体验,Arvixe的VPS在系统和应用程序支持方面比较丰富,Windows、Linux、SQL Server等一应俱全,需要的...
- 虚拟主机
百度云bch云虚拟主机怎么连接
以目前国内的公有云来说,BAT都是做得不错的,特别是阿里云,今天来说一说的是百度,最近弄了个百度的虚拟主机来试了下,顺便写下使用。 百度云 b...
- 虚拟主机
VPS 配置优化笔记
VPS(Virtual Private Server 虚拟专用服务器)技术,将一部服务器分割成多个虚拟专享服务器的优质服务。每个VPS都可分配独立公网IP地址、独立操作系统、独立...
- 虚拟主机
Linux虚拟主机管理系统directadmin使用中文教程
本文主要讲解Linux虚拟主机管理系统directadmin使用中文教程,有使用linux系统虚拟主机的朋友可以参考下...