Apache httpd.conf配置文件 3(虚拟主机)

### Section 3: Virtual Hosts 第三部分 虚拟主机


注意:在使用虚拟主机前,请先检查  http.conf 的 辅助配置文件httpd-vhosts.conf 是否注释

# Virtual hosts
#Include conf/extra/httpd-vhosts.conf

此命令是否被注释,若被注释,请先去除 Include前的 #,使虚拟主机配置生效。

然后打开Apache目录下 /conf/extra/httpd-vhosts.conf  此文件  开始配置



# VirtualHost: If you want to maintain multiple domains/hostnames on your 虚拟主机:如果你想维持多个域名和主机在你的机器上,你可

# machine you can setup VirtualHost containers for them. Most configurations 设置虚拟主机。大多数配置信息只使用基于名字的虚拟主机

# use only name-based virtual hosts so the server doesn't need to worry about 因此服务器 不必担心IP地址的问题

# IP addresses. This is indicated by the asterisks in the directives below. 下面的命令以*号代替虚拟主机名

#

# Please see the documentation at 请参看文档 地址……

# <URL:http://httpd.apache.org/docs/2.2/vhosts/>

# for further details before you try to setup virtual hosts. 在你设置虚拟主机前请了解详细情况

#

# You may use the command line option '-S' to verify your virtual host 你可以用命令行选项 -S 来核实你虚拟主机的配置

# configuration.

#

# Use name-based virtual hosting. 使用基于名字的虚拟主机

#

#NameVirtualHost *:80
如果您要配置基于域名的虚拟主机,如果是基于ip地址的可以将本行注释。
NameVirtualHost
指令就是您必须的指令之一。尽管addr参数可以使用主机名,但建议您还是使用IP地址。比如:
NameVirtualHost 111.22.33.44
请注意,<VirtualHost>指令的参数必须与NameVirtualHost指令的参数完全匹配。
NameVirtualHost 1.2.3.4
<VirtualHost 1.2.3.4>

#

# NOTE: NameVirtualHost cannot be used without a port specifier 注意:命名虚拟主机没有指定端口不能使用

# (e.g. :80) if mod_ssl is being used, due to the nature of the 例如(xxx:80) 如果使用ssl模块,是因为SSL协议的性质

# SSL protocol.

#

#

# VirtualHost example: 虚拟主机 例子

# Almost any Apache directive may go into a VirtualHost container. 几乎任何apache指令都可以加入 虚拟主机容器

# The first VirtualHost section is used for requests without a known 第一个虚拟主机用于 没有已知服务器域名的请求

# server name.

#

#<VirtualHost *:80> 添加实例

# ServerAdmin webmaster@dummy-host.example.com 管理员邮箱

# DocumentRoot /www/docs/dummy-host.example.com 文档根目录

# ServerName dummy-host.example.com 服务器名字(域名)

# ErrorLog logs/dummy-host.example.com-error_log 错误日志

# CustomLog logs/dummy-host.example.com-access_log common 对服务器的请求进行记录的日志

#</VirtualHost>



  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值