在之前LAMP環(huán)境下虛擬主機(jī)配置(基于IP) 繼續(xù)做這個(gè)基于域名的虛擬主機(jī)配置焚碌,只需要修改之前的配置內(nèi)容即可奸腺。
一、首先修改一下apache的配置文件
- 首先修改一下配置文件中的
#NameVirtualHost *:80
,修改內(nèi)容如下圖所示躯概,192.168.3.112
值得是dns sever的地址君珠,即Linux本機(jī)IP
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
- 然后到文件末尾修改之前的虛擬主機(jī)配置文件椭坚,如下所示:
<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服務(wù)
[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
- 重啟服務(wù)
[root@localhost named]# service named restart
停止 named:. [確定]
啟動 named: [確定]
[root@localhost named]#