Build Web site hosting based on domain name.
Web Virtual Host Server |
centos6.5 |
192.168.200.202 |
Building a domain-based virtual host |
DNS, FTP server |
centos6.5 |
192.168.200.254 |
Provides DNS resolution, FTP download |
1: Set DNS resolution on the DNS server:
Modify the DNS configuration file, set the zone file name and location.
[Email protected] ~]# Cd/var/named/chroot/etc/[[email protected] etc]# vi named.conf [[email protected] ~]# Cat/var/nam ed/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";};
Configure the zone file to add records. Two virtual hosts to build two zone files,
Www.leslie.com.zone and Www.leslie.cn.zone, respectively.
[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
Restart the named service when Setup is complete:
[[email protected] named]#/etc/init.d/named restart stop named:. [OK] start named: [OK]
Analytical testing:
[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
To install the HTTPD service:
Install with Yum:
[[email protected] ~]# yum-y install httpd &>>/dev/null # #红色部分是不看输出内容, no information displayed
Editing a configuration file/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>
The new Web page root directory is the same as in DocumentRoot in the configuration file:
[[email protected] conf]# cd/var/www/html/[[email protected] html]# mkdir www.leslie.com[[email protected] html]# mkdir W Ww.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
Restart HTTPD Service
[[email protected] ~]#/etc/init.d/httpd restart stop httpd: [OK] starting httpd: Determine
Testing Services:
[[email protected] ~]# NETSTAT-UTPLN |grep httpdtcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 53492/httpd
Test:
[[email protected] ~]# elinks--dump www.leslie.com www.leslie.com[[email protected] ~]# elinks--dump www.leslie.cn W ww.leslie.cn
This article is from the "longing for Technology small white" blog, please make sure to keep this source http://lesliecheung.blog.51cto.com/12622169/1956240
HTTPD Domain-based virtual host