1. Configure DNS resolution
[Root @ server ~] #
CAT/etc/RedHat-release
Red Hat Enterprise Linux Server Release 6.2 (Santiago)
[Root @ server ~] #
Uname-R
2.6.32-220. el6.i686
[Root @ server ~] #
Yum install bind *-y
[Root @ server ~] #
Vim/etc/named. conf
[Root @ server ~] #
CAT/etc/named. conf
Options {Listen-on port 53 {Any ;}; listen-on-v6 port 53 {Any ;}; directory "/var/named "; dump-file "/var/named/data/cache_dump.db"; Statistics-file "/var/named/data/named_stats.txt "; memstatistics-file "/var/named/data/named_mem_stats.txt"; allow-query {Any ;}; recursion yes; DNSSEC-enable yes; DNSSEC-validation yes; DNSSEC-lookaside auto; /* path to isc dlv key */bindkeys-file "/etc/named. iscdlv. key ";}; Logging {channel default_debug {file" Data/named. run "; severity dynamic ;};}; zone ". "In {type hint; file" named. CA ";}; zone" sxkeji.com.cn "in {type master; file" sxkeji.com.cn. zone ";};
[Root @ server ~] #CP/var/named. localhost/var/named/sxkeji.com.cn. Zone
[Root @ server ~] #Vim/var/named/sxkeji.com.cn. Zone
[Root @ server ~] #CAT/var/named/sxkeji.com.cn. Zone
$ TTL 1D @ in soasxkeji.com.cn rname. invalid. (0; serial1d; refresh1h; retry1w; expire3h); minimumns @ A 192.168.10.199wwwa 192.168.10.199maila 192.168.10.199
[Root @ server ~] #Service named restart
Test whether DNS resolution is successful
[Root @ server ~] #Host www.sxkeji.com.cn
Www.sxkeji.com.cn has address 192.168.10.199
[Root @ server ~] #Host mail.sxkeji.com.cn
Mail.sxkeji.com.cn has address 192.168.10.199
[Root @ server ~] #
2. Configure the nginx Virtual Host
[Root @ server ~] #Vim/usr/local/nginx/CONF/nginx. conf
[Root @ server ~] #Grep-ve "# | ^ $"/usr/local/nginx/CONF/nginx. conf
Worker_processes 1;
Events {
Worker_connections 1024;
}
HTTP {
Include mime. types;
Default_type application/octet-stream;
Sendfile on;
Keepalive_timeout 65;
Server {
Listen 80;
SERVER_NAME localhost;
Location /{
Root HTML;
Index index.html index.htm;
}
Error_page 500 502 503 x.html;
Location =/50x.html {
Root HTML;
}
}
Server {
Listen 80;
SERVER_NAME mail.sxkeji.com.cn;
Location /{
Root/usr/local/nginx/html/mail.sxkeji.com;
Index index.html index.htm;
}
}
Include/usr/local/nginx/CONF/vhosts/sxkeji. conf;
# Include: This is modular, and the virtual host is independent into a configuration file.
# The server section in italic text above directly implements a VM in the master configuration file
}
[Root @ server ~] #CAT/usr/local/nginx/CONF/vhosts/sxkeji. conf# You need to create the vhosts directory and the home directory.
Server {Listen 80; SERVER_NAME www.sxkeji.com.cn; access_log logs/sxkeji.com. log; Location/{index index.html; root/usr/local/nginx/html/sxkeji.com ;}}
[Root @ server ~] #
3. Check whether the test is successful.
[Root @ server ~] #Kill-HUP 'cat/usr/local/nginx/logs/nginx. pid'# Restart nginx
[Root @ server ~] #Vim/usr/local/nginx/html/sxkeji.com/index.html
[Root @ server ~] #Vim/usr/local/nginx/html/mail.sxkeji.com/index.html
[Root @ server ~] #CAT/usr/local/nginx/html/mail.sxkeji.com/index.html
Mail.sxkeji.com.cn
[Root @ server ~] #CAT/usr/local/nginx/html/sxkeji.com/index.html
Www.sxkeji.com.cn
[Root @ server ~] #Elinks -- dump 127.0.0.1
Hello!
[Root @ server ~] #Elinks -- dump mail.sxkeji.com.cn
Mail.sxkeji.com.cn
[Root @ server ~] #Elinks -- dump www.sxkeji.com.cn
Www.sxkeji.com.cn
[Root @ server ~] #
######## You can close the ticket. Next time you continue to configure the port-based VM ########