不用配置直接启动
systemctl start named
安装http
yum install httpd
配置httpd
vi /etc/httpd/conf/httpd.conf
直接找到ServerName改为
ServerName dns.example.com:80
打开
vim /var/www/html/index.html
输入helloword测试
systemctl restart httpd
测试网址:在Linux和window测试(可能会扣分)
http://www.example.com
如果没有显示hellword试一下
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
vim /etc/httpd/conf/httpd.conf
跳到3.26,在下面添加
NameVirtualHost 172.18.111.203
<VirtualHost abc.example.com>
ServerAdmin admin@example.com
DocumentRoot "/var/www/web3"
ServerName abc.example.com
DirectoryIndex index.html
ErrorLog logs/web3/error_log
CustomLog logs/web3/access_log common
</VirtualHost>
<VirtualHost xyz.example.com>
ServerAdmin admin@example.com
DocumentRoot "/var/www/web4"
ServerName xyz.example.com
DirectoryIndex index.html
ErrorLog logs/web4/error_log
CustomLog logs/web4/access_log combined
</VirtualHost>
正向配置name文件
vim /var/named/data/example.com.zone
内容在下面添加
abc IN A 172.18.111.203
xyz IN A 172.18.111.203
反向
vim /var/named/data/172.18.111.arpa
添加
203 PTR abc.example.com.
PTR xyz.example.com.
ifconfig ens33:3 172.18.111.203 netmask 255.255.255.0
systemctl restart named
mkdir -p /var/www/web4
mkdir -p /var/www/web3
vim /var/www/web4/index.html
输入 hello web4
vim /var/www/web3/index.html
mkdir -p /etc/httpd/logs/web3
mkdir -p /etc/httpd/logs/web4
touch /etc/httpd/logs/web3/error_log
touch /etc/httpd/logs/web3/access_log
touch /etc/httpd/logs/web4/error_log
touch /etc/httpd/logs/web4/access_log
systemctl restart httpd
yum install nscd -y
systemctl restart nscd
分别在 Windows 和 Linux 的浏览器测试
http://abc.example.com
http://xyz.example.com
wget http://xyz.example.com
cat /etc/httpd/logs/web4/access_log
cat /etc/httpd/logs/web3/access_log
wget http://abc.example.com
cat /etc/httpd/logs/web3/access_log