cm-0716

导航

apche 虚拟主机设置

<要求>
两个不同的域名 www.got7.com 和www.wgayi.com 指向同一个IP地址
当在浏览器中输入不同的域名时。对应不同的网站根目录

备注:域名got7,wgayi,纯属个人爱好,请忽略


<配置>
1.httpd配置
1.1 打开apache目录下httpd,conf文件f找到如下模块:

 

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

去掉Include前面的#,这样就开启了httpd-vhosts虚拟主机文件。


1.2 编辑/usr/local/httpd/conf/extra/httpd-vhost.conf

<Directory "/web">
Require all granted
</Directory>
<VirtualHost *:80>
    ServerAdmin admin@got7.com
    DocumentRoot "/web/got7"
    ServerName www.got7.com
    ServerAlias www.got7.com
    ErrorLog "logs/www.got7.com-error_log"
    CustomLog "logs/www.got7.com-access_log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin admin@wgayi.com
    DocumentRoot "/web/wgayi"
    ServerName www.wgayi.com
    ServerAlias www.wgayi.com
    ErrorLog "logs/www.wgayi.com-error_log"
    CustomLog "logs/www.wgayi.com-access_log" common
</VirtualHost>


2.域名服务器的配置
2.1 主配置文件

 

zone "got7.com" IN {
        type master;
        file "got7.com.zone";
        allow-update { none; };
};

zone "wgayi.com" IN {
        type master;
        file "wgayi.com.zone";
        allow-update { none; };
};
zone "0.10.in-addr.arpa" IN {
        type master;
        file "10.0.rev";
        allow-update { none; };
};


2.2 正向区域数据文件

#cd /var/named
#vim got7.com.zone $TTL
86400 @ IN SOA dns.got7.com. admin.got7.com. ( 20160706 1D 30M 1W 3H ) IN NS dns.got7.com. IN MX 0 mail.got7.com. dns IN A 10.0.7.15 mail IN A 10.0.7.15 www IN A 10.0.7.15 # vim wgayi.com.zone $TTL 86400 @ IN SOA dns.wgayi.com. admin.wgayi.com. ( 20160706 1D 30M 1W 3H ) IN NS dns.wgayi.com. IN MX 0 mail.wgayi.com. dns IN A 10.0.7.15 mail IN A 10.0.7.15 www IN A 10.0.7.15

2.3 反向区域数据文件

# vim 10.0.rev
$TTL 86400
@       IN      SOA     dns.got7.com.   admin.got7.com. (
                20160706
                1D
                30M
                1W
                3H )
        IN      NS      dns.got7.com.
7.15    IN      PTR     mail.got7.com.
7.15    IN      PTR     mail.wgayi.com.
7.15    IN      PTR     www.got7.com.
7.15    IN      PTR     www.wgayi.com.

 建立不同域名对应的网站根目录

#mkdir /web
#cd /web
#mkdir got7 wgayi
#cd got7
#cat index.html
this is got7
#cd ../wgayi/
#cat index.html
this is wgaga


测试:将测试机器的dns设置为dns服务器的ip地址



posted on 2016-07-06 16:17  cm-0716  阅读(137)  评论(0编辑  收藏  举报