在之前LAMP环境下虚拟主机配置(基于IP) 继续做这个基于域名的虚拟主机配置,只需要修改之前的配置内容即可。
一、首先修改一下apache的配置文件
- 首先修改一下配置文件中的
#NameVirtualHost *:80
,修改内容如下图所示,192.168.3.112
值得是dns sever的地址,即Linux本机IP
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
- 然后到文件末尾修改之前的虚拟主机配置文件,如下所示:
<VirtualHost 192.168.3.112:80>
ServerAdmin www.zzqa.com
DocumentRoot /var/www/html/zzqa/
ServerName www.zzqa.com
ErrorLog logs/dummy-host.zzqa.com-error_log
CustomLog logs/dummy-host.zzqa.com-access_log common
</VirtualHost>
<VirtualHost 192.168.3.112:80>
ServerAdmin www.zzqb.com
DocumentRoot /var/www/html/zzqb/
ServerName www.zzqb.com
ErrorLog logs/dummy-host.zzqb.com-error_log
CustomLog logs/dummy-host.zzqb.com-access_log common
</VirtualHost>
<VirtualHost 192.168.3.112:80>
ServerAdmin www.zzqc.com
DocumentRoot /var/www/html/zzqc/
ServerName www.zzqc.com
ErrorLog logs/dummy-host.zzqc.com-error_log
CustomLog logs/dummy-host.zzqc.com-access_log common
</VirtualHost>
修改完保存并退出
重启apache服务
[root@localhost ~]# service httpd restart
二、修改DNS解析配置
[root@localhost ~]# cd /var/named/
[root@localhost named]# ls
data dynamic named.ca named.empty named.localhost named.loopback sec.com slaves zzqa.com zzqb.com zzqc.com
[root@localhost named]# vim zzqa.com
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
@ IN A 192.168.3.112
www IN A 192.168.3.112
game IN A 192.168.3.112
[root@localhost named]# vim zzqb.com
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
@ IN A 192.168.3.112
www IN A 192.168.3.112
game IN A 192.168.3.112
[root@localhost named]# vim zzqc.com
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
@ IN A 192.168.3.112
www IN A 192.168.3.112
game IN A 192.168.3.112
- 重启服务
[root@localhost named]# service named restart
停止 named:. [确定]
启动 named: [确定]
[root@localhost named]#