Apache虛擬主機的配置和泛域名解析實現(xiàn)代碼
更新時間:2012年03月11日 00:28:19 作者:
Apache虛擬主機的配置和泛域名解析實現(xiàn)代碼,需要的朋友可以參考下
虛擬主機的配置
基于IP地址的虛擬主機配置
Listen 80
DocumentRoot /www/jb51
ServerName www.fzitv.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.fzitv.net
DocumentRoot /www/jb51-8080
ServerName www.fzitv.net
DocumentRoot /www/example2-80
ServerName www.jb51.org
DocumentRoot /www/example2-8080
ServerName www.example2.org
單個IP地址的服務(wù)器上基于域名的虛擬主機配置:
# 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.fzitv.net
ServerAlias jb51.net. *.jb51.net
# Other directives here
DocumentRoot /www/example2
ServerName www.example2.org
# Other directives here
在多個IP地址的服務(wù)器上配置基于域名的虛擬主機:
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.fzitv.net
# Other directives here …
DocumentRoot /www/example2
ServerName www.example2.org
# Other directives here …
在不同的端口上運行不同的站點:
基于多端口的服務(wù)器上配置基于域名的虛擬主機。
Listen 80
Listen 8080
NameVirtualHost 172.20.30.40:80
NameVirtualHost 172.20.30.40:8080
ServerName www.fzitv.net
DocumentRoot /www/domain-80
ServerName www.fzitv.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.fzitv.net
DocumentRoot /www/example2
ServerName www.example2.org
DocumentRoot /www/example3
ServerName www.example3.net
網(wǎng)站泛域名解析
添加一個虛擬主機配置(如下):
DocumentRoot d:/web/jb51 # 網(wǎng)站根目錄的絕對路徑
ServerName www.fzitv.net # 網(wǎng)站域名
ServerAlias *.jb51.net # 網(wǎng)站泛域名
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>
基于IP地址的虛擬主機配置
Listen 80
DocumentRoot /www/jb51
ServerName www.fzitv.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.fzitv.net
DocumentRoot /www/jb51-8080
ServerName www.fzitv.net
DocumentRoot /www/example2-80
ServerName www.jb51.org
DocumentRoot /www/example2-8080
ServerName www.example2.org
單個IP地址的服務(wù)器上基于域名的虛擬主機配置:
# 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.fzitv.net
ServerAlias jb51.net. *.jb51.net
# Other directives here
DocumentRoot /www/example2
ServerName www.example2.org
# Other directives here
在多個IP地址的服務(wù)器上配置基于域名的虛擬主機:
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.fzitv.net
# Other directives here …
DocumentRoot /www/example2
ServerName www.example2.org
# Other directives here …
在不同的端口上運行不同的站點:
基于多端口的服務(wù)器上配置基于域名的虛擬主機。
Listen 80
Listen 8080
NameVirtualHost 172.20.30.40:80
NameVirtualHost 172.20.30.40:8080
ServerName www.fzitv.net
DocumentRoot /www/domain-80
ServerName www.fzitv.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.fzitv.net
DocumentRoot /www/example2
ServerName www.example2.org
DocumentRoot /www/example3
ServerName www.example3.net
網(wǎng)站泛域名解析
添加一個虛擬主機配置(如下):
DocumentRoot d:/web/jb51 # 網(wǎng)站根目錄的絕對路徑
ServerName www.fzitv.net # 網(wǎng)站域名
ServerAlias *.jb51.net # 網(wǎng)站泛域名
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>
您可能感興趣的文章:
相關(guān)文章
CentOS下Lighttpd Web服務(wù)器安裝與配置方法
CentOS下Lighttpd Web服務(wù)器安裝與配置方法,需要的朋友可以參考下。2011-04-04
分享apache http服務(wù)器設(shè)置虛擬主機的方法
對于多個域名綁定到一臺服務(wù)器上,需要進行虛擬主機(virtual host)相關(guān)的設(shè)置,假設(shè)我要設(shè)置fuwu.jb51.net到一臺服務(wù)器上,應(yīng)該如何做虛擬主機的設(shè)置呢?2011-08-08
linux cat more less顯示文件的區(qū)別
liunx下幾個常見的用于顯示文件命令的區(qū)別2008-06-06
Linux系統(tǒng)下安裝rz/sz命令及使用說明(詳解)
下面小編就為大家?guī)硪黄狶inux系統(tǒng)下安裝rz/sz命令及使用說明(詳解)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧,祝大家游戲愉快哦2016-12-12

