售前咨询
技术支持
渠道合作

apache如何在80端口建立多个域名站点,apache建立多个网站的方法 – Apache

一台服务器安装了APACHE,如何绑定多个域名和网站内容呢?最简单的方法当然就是不同的站用不同的端口。但这样就需在域名后加入端口号才能访问,不能直接以域名访问。另一个方法就是使用主机头名虚所主机了。打开APACHE配置文件httpd.conf 在最后一行输入以下代码

#第一个主机,80端口
DocumentRoot “D:/root/abc” #指向本地位置
ServerName www.trustauth.cn #主机名称(注意这个很重要,就是你的域名,准确输入才能成功)
#结束第一个主机配置
#第二个主机,80端口
DocumentRoot “D:/root/def” #指向本地位置
ServerName www.trustauth.cn #主机名称

#第三个主机,80端口
DocumentRoot “D:/root/ghi” #指向本地位置
ServerName www.trustauth.cn #主机名称

Aapche 如果需要绑定多个域名到一个IP上,是支持的。需要注意以下2点:

1 必须要开启 NameVirtualHost开关选项,

2 NameVirtualHost 需要指定具体的端口

例如”:80″,跟对应,否则会报错:

mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results。

翻译过来就是: NameVirtualHost 地址,指定端口和不指定端口混合使用是不支持的,将会产生未逾期的后果。

未逾期的后果就是: 第2个不起作用,仅当一个站点设置起作用。

完整的例子:

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#

ServerAdmin hot@vip.qq.com
DocumentRoot /usr/local/apache2/htdocs1
ServerName www.trustauth.cn
ErrorLog logs/trustauth.cn-error_log
CustomLog logs/trustauth.cn-access_log common

ServerAdmin hot@vip.qq.com
DocumentRoot /usr/local/apache2/htdocs2
ServerName www.trustauth.cn
ErrorLog logs/trustauth.cn-error_log
CustomLog logs/trustauth.cn-access_log common

上一篇:

下一篇:

相关新闻

 

领取优惠
免费预约

申请试用SSL证书

提交成功!

咨询客服