Apache虛擬主機(jī)的配置和泛域名解析實(shí)現(xiàn)代碼
更新時(shí)間:2012年03月11日 00:28:19 作者:
Apache虛擬主機(jī)的配置和泛域名解析實(shí)現(xiàn)代碼,需要的朋友可以參考下
虛擬主機(jī)的配置
基于IP地址的虛擬主機(jī)配置
Listen 80
DocumentRoot /www/jb51
ServerName www.dhdzp.com
DocumentRoot /www/jb512
ServerName www.jb512.org
基于IP和多端口的虛擬主機(jī)配置
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.dhdzp.com
DocumentRoot /www/jb51-8080
ServerName www.dhdzp.com
DocumentRoot /www/example2-80
ServerName www.jb51.org
DocumentRoot /www/example2-8080
ServerName www.example2.org
單個(gè)IP地址的服務(wù)器上基于域名的虛擬主機(jī)配置:
# 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.dhdzp.com
ServerAlias jb51.net. *.jb51.net
# Other directives here
DocumentRoot /www/example2
ServerName www.example2.org
# Other directives here
在多個(gè)IP地址的服務(wù)器上配置基于域名的虛擬主機(jī):
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.dhdzp.com
# Other directives here …
DocumentRoot /www/example2
ServerName www.example2.org
# Other directives here …
在不同的端口上運(yùn)行不同的站點(diǎn):
基于多端口的服務(wù)器上配置基于域名的虛擬主機(jī)。
Listen 80
Listen 8080
NameVirtualHost 172.20.30.40:80
NameVirtualHost 172.20.30.40:8080
ServerName www.dhdzp.com
DocumentRoot /www/domain-80
ServerName www.dhdzp.com
DocumentRoot /www/domain-8080
ServerName www.example2.org
DocumentRoot /www/otherdomain-80
ServerName www.example2.org
DocumentRoot /www/otherdomain-8080
基于域名和基于IP的混合虛擬主機(jī)的配置:
Listen 80
NameVirtualHost 172.20.30.40
DocumentRoot /www/jb51
ServerName www.dhdzp.com
DocumentRoot /www/example2
ServerName www.example2.org
DocumentRoot /www/example3
ServerName www.example3.net
網(wǎng)站泛域名解析
添加一個(gè)虛擬主機(jī)配置(如下):
DocumentRoot d:/web/jb51 # 網(wǎng)站根目錄的絕對(duì)路徑
ServerName www.dhdzp.com # 網(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地址的虛擬主機(jī)配置
Listen 80
DocumentRoot /www/jb51
ServerName www.dhdzp.com
DocumentRoot /www/jb512
ServerName www.jb512.org
基于IP和多端口的虛擬主機(jī)配置
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.dhdzp.com
DocumentRoot /www/jb51-8080
ServerName www.dhdzp.com
DocumentRoot /www/example2-80
ServerName www.jb51.org
DocumentRoot /www/example2-8080
ServerName www.example2.org
單個(gè)IP地址的服務(wù)器上基于域名的虛擬主機(jī)配置:
# 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.dhdzp.com
ServerAlias jb51.net. *.jb51.net
# Other directives here
DocumentRoot /www/example2
ServerName www.example2.org
# Other directives here
在多個(gè)IP地址的服務(wù)器上配置基于域名的虛擬主機(jī):
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.dhdzp.com
# Other directives here …
DocumentRoot /www/example2
ServerName www.example2.org
# Other directives here …
在不同的端口上運(yùn)行不同的站點(diǎn):
基于多端口的服務(wù)器上配置基于域名的虛擬主機(jī)。
Listen 80
Listen 8080
NameVirtualHost 172.20.30.40:80
NameVirtualHost 172.20.30.40:8080
ServerName www.dhdzp.com
DocumentRoot /www/domain-80
ServerName www.dhdzp.com
DocumentRoot /www/domain-8080
ServerName www.example2.org
DocumentRoot /www/otherdomain-80
ServerName www.example2.org
DocumentRoot /www/otherdomain-8080
基于域名和基于IP的混合虛擬主機(jī)的配置:
Listen 80
NameVirtualHost 172.20.30.40
DocumentRoot /www/jb51
ServerName www.dhdzp.com
DocumentRoot /www/example2
ServerName www.example2.org
DocumentRoot /www/example3
ServerName www.example3.net
網(wǎng)站泛域名解析
添加一個(gè)虛擬主機(jī)配置(如下):
DocumentRoot d:/web/jb51 # 網(wǎng)站根目錄的絕對(duì)路徑
ServerName www.dhdzp.com # 網(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>
您可能感興趣的文章:
- apache虛擬主機(jī)中設(shè)置泛域名解析的方法
- 分享三種Apache配置虛擬主機(jī)的方式
- apache虛擬主機(jī)三種配置方式小結(jié)
- apache服務(wù)器一個(gè)ip(如:127.0.0.1)和多個(gè)域名(虛擬主機(jī))的綁定
- Apache 配置多端口 多虛擬主機(jī) 局域網(wǎng)訪(fǎng)問(wèn)示例
- 如何配置apache虛擬主機(jī)的實(shí)例小結(jié)
- 本地機(jī)apache配置基于域名的虛擬主機(jī)詳解
- windows apache多端口虛擬主機(jī)配置方法
- apache中偽靜態(tài)配置和使用(Apache虛擬主機(jī)下Discuz偽靜態(tài))
- Apache實(shí)現(xiàn)本地建立泛域名虛擬主機(jī)的方法
相關(guān)文章
apache密碼生成工具h(yuǎn)tpasswd使用詳解
本文主要介紹了1、 htpasswd的作用與安裝,2、 htpasswd命令詳解,3、 htpasswd的實(shí)例,4、 htpasswd的應(yīng)用,有需要的小伙伴參考下2015-01-01
CentOS下Lighttpd Web服務(wù)器安裝與配置方法
CentOS下Lighttpd Web服務(wù)器安裝與配置方法,需要的朋友可以參考下。2011-04-04
Linux 單個(gè)tomcat多實(shí)例部署shell腳本詳解
這篇文章主要介紹了Linux 單個(gè)tomcat多實(shí)例部署shell腳本詳解的相關(guān)資料,需要的朋友可以參考下2017-02-02
分享apache http服務(wù)器設(shè)置虛擬主機(jī)的方法
對(duì)于多個(gè)域名綁定到一臺(tái)服務(wù)器上,需要進(jìn)行虛擬主機(jī)(virtual host)相關(guān)的設(shè)置,假設(shè)我要設(shè)置fuwu.jb51.net到一臺(tái)服務(wù)器上,應(yīng)該如何做虛擬主機(jī)的設(shè)置呢?2011-08-08
linux cat more less顯示文件的區(qū)別
liunx下幾個(gè)常見(jiàn)的用于顯示文件命令的區(qū)別2008-06-06
Linux系統(tǒng)下安裝rz/sz命令及使用說(shuō)明(詳解)
下面小編就為大家?guī)?lái)一篇Linux系統(tǒng)下安裝rz/sz命令及使用說(shuō)明(詳解)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧,祝大家游戲愉快哦2016-12-12
Linux中搭建DNS域名解析服務(wù)器的詳細(xì)過(guò)程
在Linux中搭建DNS服務(wù)器涉及配置和運(yùn)行一個(gè)軟件來(lái)提供DNS服務(wù),DNS是互聯(lián)網(wǎng)上的一種系統(tǒng),它將域名轉(zhuǎn)換為對(duì)應(yīng)的IP地址,使得用戶(hù)可以通過(guò)易記的域名訪(fǎng)問(wèn)網(wǎng)站,而不是記憶一長(zhǎng)串?dāng)?shù)字,本文給大家詳細(xì)介紹了Linux中搭建DNS域名解析服務(wù)器,需要的朋友可以參考下2024-03-03

