多IP多端口apache虚拟主机的配置的设置

在很多的虚拟主机应用中由于某些原因我们常常为主机分配多个IP[TMD现在IDC的IP好贵],以下是几种多个IP或多个端品的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

 

本文链接:多IP多端口apache虚拟主机的配置的设置

转载声明:本站文章若无特别说明,皆为原创,转载请注明来源:Rexdf,谢谢!^^


此条目发表在网站建设分类目录,贴了标签。将固定链接加入收藏夹。

2 Responses to 多IP多端口apache虚拟主机的配置的设置

  1. 清风迅来说:
    Unknown Unknown

    哎..貌似我那个空间只有1个ip的说=。= 可能我申请的只是一个空间而不是一个虚拟主机…… 倒是DNS服务器有好几个……

发表回复

您的电子邮箱地址不会被公开。

*

:zsmilebig: :zsadbig: :zwiredbig: :zgreenhappy: more »

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据