Linux下Apache绑定多个域名

19. December 2015 Linux 0

假如你使用的是linux服务器。需要把 www.lezhi.ren 解析到/var/www/liian1  把www.ourlanshan.cn解析到/var/www/liian2

首先你需要找到httpd.conf文件,如果不清楚具体位置,可使用 命令 find -name httpd.conf 查找位置,然后打开
文件,
# 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 [email protected]
#    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
#
————————————————————————————————————-
# for lehzi.ren
    ServerAdmin [email protected]
    DocumentRoot /var/www/lijian1
    ServerName www.lezhi.ren
   ErrorLog logs/dummy-host.example.com-error_log
   CustomLog logs/dummy-host.example.com-access_log common
    ServerAdmin [email protected]
    DocumentRoot /var/www/lijian2
    ServerName www.ourlanshan.cn
     ErrorLog logs/dummy-host.example.com-error_log
   CustomLog logs/dummy-host.example.com-access_log common
然后重启apache,在域名商那里解析域名。域名解析成功后,就可以访问啦!


Leave a Reply

Your email address will not be published. Required fields are marked *