標籤:linux虛擬機器主機 基於網域名稱的虛擬機器主機
搭建基於網域名稱的網站虛擬機器主機。
web虛擬機器主機伺服器 |
centos6.5 |
192.168.200.202 |
搭建基於網域名稱的虛擬機器主機 |
dns、ftp伺服器 |
centos6.5 |
192.168.200.254 |
提供DNS解析,ftp下載 |
1:在dns伺服器上設定dns解析:
修改dns的設定檔,設定地區檔案名稱和所在位置。
[[email protected] ~]# cd /var/named/chroot/etc/[[email protected] etc]# vi named.conf [[email protected] ~]# cat /var/named/chroot/etc/named.conf options {listen-on port 53{ any; };forwarders { 202.106.0.20;114.114.114.114;8.8.8.8; };directory "/var/named";};zone "leslie.cn." IN {type master;file "leslie.cn.zone";};zone "leslie.com." IN {type master;file "leslie.com.zone";};
配置地區檔案,添加記錄。兩個虛擬機器主機要建兩個地區檔案,
分別是www.leslie.com.zone和www.leslie.cn.zone
[[email protected] etc]# cd ../var/named/[[email protected] named]# vi leslie.cn.zone [[email protected] ~]# cat /var/named/chroot/var/named/leslie.cn.zone $TTL 86400@INSOAleslie.cn.root.leslie.cn. (201506301H2M3W1D)@INNSns.leslie.cn.mailINMX 10mail.leslie.cn.@INA192.168.200.254mailINA192.168.200.254nsINA192.168.200.254ftpINA192.168.200.254ntpINCNAMEnswwwINA192.168.200.202
[[email protected] named]# vi leslie.com.zone [[email protected] ~]# cat /var/named/chroot/var/named/leslie.com.zone $TTL 86400@INSOAleslie.com.root.leslie.com. (201506301H2M3W1D)@INNSns.leslie.com.mailINMX 10mail.leslie.com.@INA192.168.200.254mailINA192.168.200.254nsINA192.168.200.254ftpINA192.168.200.254ntpINCNAMEnswwwINA192.168.200.202
設定完成後重啟named服務:
[[email protected] named]# /etc/init.d/named restart停止 named:. [確定]啟動 named: [確定]
解析測試:
[[email protected] named]# nslookup> server 192.168.200.254Default server: 192.168.200.254Address: 192.168.200.254#53> www.leslie.com Server:192.168.200.254Address:192.168.200.254#53Name:www.leslie.comAddress: 192.168.200.202> www.leslie.cnServer:192.168.200.254Address:192.168.200.254#53
安裝httpd服務:
使用yum安裝:
[[email protected] ~]# yum -y install httpd &>>/dev/null ##紅色部分是不看輸出內容,不顯示資訊
編輯設定檔/etc/httpd/conf/httpd.conf
277 ServerName www.leslie.com:80 990 NameVirtualHost 192.168.200.202:80 991 <VirtualHost 192.168.200.202:80> 992 ServerAdmin [email protected] 993 DocumentRoot "/var/www/html/www.leslie.com" 994 ServerName www.leslie.com 995 ErrorLog logs/www.leslie.com.com-error_log 996 CustomLog logs/www.leslie.com.com-access_log common 997 </VirtualHost> 998 <VirtualHost 192.168.200.202:80> 999 ServerAdmin [email protected] 1000 DocumentRoot "/var/www/html/www.leslie.cn" 1001 ServerName www.leslie.cn 1002 ErrorLog logs/www.leslie.cn-error_log 1003 CustomLog logs/www.leslie.cn-access_log common 1004 </VirtualHost>
建立網頁根目錄 和設定檔中DocumentRoot 中的一樣:
[[email protected] conf]# cd /var/www/html/[[email protected] html]# mkdir www.leslie.com[[email protected] html]# mkdir www.leslie.cn[[email protected] html]# echo "www.leslie.com" >>www.leslie.com/index.html[[email protected] html]# echo "www.leslie.cn" >>www.leslie.cn/index.html[[email protected] html]# cat www.leslie.com/index.html www.leslie.com[[email protected] html]# cat www.leslie.cn/index.html www.leslie.cn
重啟httpd服務
[[email protected] ~]# /etc/init.d/httpd restart停止 httpd: [確定]正在啟動 httpd: [確定]
檢測服務:
[[email protected] ~]# netstat -utpln |grep httpdtcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 53492/httpd
測試:
[[email protected] ~]# elinks --dump www.leslie.com www.leslie.com[[email protected] ~]# elinks --dump www.leslie.cn www.leslie.cn
本文出自 “嚮往技術的小白” 部落格,請務必保留此出處http://lesliecheung.blog.51cto.com/12622169/1956240
httpd基於網域名稱的虛擬機器主機