Apache多域名绑定手记


打开appache下面的httpd.conf文件

示例如下:

#NameVirtualHost *:80

#
# 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.
#
#<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>

\#号是起注释作用的
实例

NameVirtualHost 127.0.0.1:80 //如果没有此项,所有域名都指向第一个目录

<VirtualHost 127.0.0.1:80> //ip及端口
ServerAdmin admin@admin.com //管理邮箱地址
DocumentRoot E:\a //绑定的目录
ServerName www.a.com //绑定的域名
ErrorLog logs/a-error_log //错误的日志
CustomLog logs/a_log common //客户日志
</VirtualHost>

<VirtualHost 203.171.228.123:80>
ServerAdmin admin@admin.com
DocumentRoot E:\b
ServerName www.b.com
ErrorLog logs/b-error_log
CustomLog logs/b-access_log common
</VirtualHost>

<VirtualHost 127.0.0.1:80>
ServerAdmin admin@admin.com
DocumentRoot E:\c
ServerName www.c.com
ErrorLog logs/c-error_log
CustomLog logs/c_log common
</VirtualHost>

要绑定多少个域名,就添加多少个记录

声明:初心|版权所有,违者必究|如未注明,均为原创|本网站采用BY-NC-SA协议进行授权

转载:转载请注明原文链接 - Apache多域名绑定手记


愿你勿忘初心,并从一而终