【轉】Apache虛擬主機的配置和泛解析域名的綁定

基於IP地址的虛擬主機配置
  Listen 80
  DocumentRoot /www/example1
  ServerName www.example1.com
  DocumentRoot /www/example2
  ServerName www.example2.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/example1-80
  ServerName www.example1.com
  DocumentRoot /www/example1-8080
  ServerName www.example1.com
  DocumentRoot /www/example2-80
  ServerName www.example1.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/example1
  ServerName www.example1.com
  ServerAlias example1.com. *.example1.com
  # 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/example1
  ServerName www.example1.com
  # 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.example1.com
  DocumentRoot /www/domain-80
  ServerName www.example1.com
  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/example1
  ServerName www.example1.com
  DocumentRoot /www/example2
  ServerName www.example2.org
  DocumentRoot /www/example3
  ServerName www.example3.net

  網站泛域名解析
  添加一個虛擬主機配置(以下):
  DocumentRoot d:/web/server110.com # 網站根目錄的絕對路徑
  ServerName www.server110.com # 網站域名
  ServerAlias *.server110.com # 網站泛域名html

原文地址:http://www.server110.com/apache/201310/2783.htmlweb

相關文章
相關標籤/搜索