如果这是用于本地 PC(测试和开发),则需要在 windows 中编辑主机文件或在 linux 中编辑主机。
我通过为本地网络(ubuntu 服务器)创建虚拟 DNS 服务器来本地解决了我遇到的问题。
install bind
apt-get install bind9 -y
cd /etc/bind
vim named.conf.options
And uncomment forwarders and two rows bellow and instead of 0.0.0.0 enter google's dns IP (8.8.8.8).
service bind9 restart
vim named.conf.options
zone "YOURDOMAIN NAME" {
type master;
file "db.site.com";
notify yes;
};
cp db.local /var/cache/bind/db.site.com
cd /var/cache/bind/
vim db.sajt1.rs
$TTL 604800
@ IN SOA admin. admin.itlink.edu. (
2 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
IN NS ns.YOURDOMAINNAMEHERE.
IN A 192.168.1.10 replace this with the IP of your PC that has apache installed
ns A 192.168.1.10 replace this with the IP of your PC that has apache installed
www A 192.168.1.10 replace this with the IP of your PC that has
service bind9 restart
如果您将 ubuntu 服务器的 IP 作为您的 dns,一切都会正常运行(因为所有无法解析的站点都将被发送到谷歌 DNS,它会为您完成)。但这仅适用于本地网络。