DNS+apache实现同ip多域名

1,apache配置
# vim /etc/httpd/conf/httpd.conf
ServerName 服务器ip ---大概在第95行
<Directory 网页目录>
        AllowOverride none
        Require all granted
</Directory>
<Directory 网页目录>
        AllowOverride none
        Require all granted
</Directory>
......
# vim /etc/httpd/conf.d/虚拟主机目录(vhost.conf)
<VirtualHost 192.168.100.134>
        DocumentRoot /web1	---文件目录
        DirectoryIndex index.html	---目录索引 
        ServerName www.xx.com	--域名名称
</VirtualHost>

<VirtualHost 192.168.100.134>
        DocumentRoot /web2
        DirectoryIndex index.html
        ServerName www.jj.com
</VirtualHost>

......
# systemctl restart httpd
# systemctl enable httpd
2,DNS配置
# vim /etc/named.conf
zone "xx.com" IN {
        type master;
        file "xx.com.zone";
};
zone "jj.com" IN {
        type master;
        file "jj.com.zone";
};
zone "100.168.192.in-addr.arpa" IN {
        type master;
        file "134.zone";
};

# vim /var/named/xx.com.zone
# vim /var/named/jj.com.zone
# vim /var/named/134.zone

注意的是:在DNS配置过程中写域的时候容易出错,哈哈哈,是我容易出错 1,正反向文件的开头都是"dns.xx.com.
root.xx.com.“第一个"dns.xx.com"是替换了原文件中的”@",需注意每个域名写完后要写一个"." 2,文件中"@
IN NS dns.xx.com."这一句不管正反向文件都相同 3,正向域名解析是"dns IN A
192.168.100.134"这样写 4,反向域名解析是"134 IN PTR www.xx.com."这样写

# vim /etc/resolv.conf
添加一句nameserver 192.168.100.134(自己的服务器ip)
# vim /etc/sysconfig/network-scripts/ifcfg-ens33(在网卡里面添加dns解析)
DNS1=ip
......
# nslookup	---测试可否解析域名或者ip
# curl 地址/域名 ---可否assess网页
上一篇:Django setting.py设置时区


下一篇:python测试开发django-18.admin后台中文版