DNS<\/a>\u57df\u540d\u89e3\u6790\u670d\u52a1<\/strong><\/p>\n[root@localhost ~]# yum -y install bind\r\n\/\/\u5b89\u88c5DNS\u670d\u52a1\u7684bind\u5305\r\n[root@localhost ~]# vim \/etc\/named.conf \r\n\/\/\u7f16\u8f91\u4e3b\u914d\u7f6e\u6587\u4ef6\r\n\r\noptions {\r\n listen-on port 53 { any; };\r\n ##\u5c06\u76d1\u542c\u5730\u5740127.0.0.1\u66ff\u6362\u4e3aany,\r\n listen-on-v6 port 53 { ::1; };\r\n directory "\/var\/named";\r\n dump-file "\/var\/named\/data\/cache_dump.db";\r\n statistics-file "\/var\/named\/data\/named_stats.txt";\r\n memstatistics-file "\/var\/named\/data\/named_mem_stats.txt";\r\n recursing-file "\/var\/named\/data\/named.recursing";\r\n secroots-file "\/var\/named\/data\/named.secroots";\r\n allow-query { any; };\r\n ##\u5c06\u6388\u6743localhost\u66ff\u6362\u4e3aany\r\n\r\n[root@localhost ~]# vim \/etc\/named.rfc1912.zones \r\n\/\/\u7f16\u8f91\u4e24\u4e2a\u57df\u540d\u7684\u533a\u57df\u914d\u7f6e\u6587\u4ef6\r\n\r\nzone "kgc.com" IN { \r\n type master;\r\n file "kgc.com.zone";\r\n allow-update { none; };\r\n}; \r\n\r\nzone "accp.com" IN { \r\n type master;\r\n file "accp.com.zone";\r\n allow-update { none; };\r\n}; \r\n\r\n[root@localhost ~]# cd \/var\/named\r\n[root@localhost named]# cp -p named.localhost kgc.com.zone \r\n[root@localhost named]# cp -p named.localhost accp.com.zone \r\n[root@localhost named]# vim kgc.com.zone \r\n\/\/\u7f16\u8f91kgc\u57df\u540d\u533a\u57df\u6570\u636e\u914d\u7f6e\u6587\u4ef6\r\n$TTL 1D\r\n@ IN SOA @ rname.invalid. (\r\n 0 ; serial\r\n 1D ; refresh\r\n 1H ; retry\r\n 1W ; expire\r\n 3H ) ; minimum\r\n NS @\r\n A 127.0.0.1\r\nwww IN A 192.168.235.158\r\n##\u5220\u9664\u539f\u6765\u672b\u884c\u7684\u5185\u5bb9,\u6dfb\u52a0\u57df\u540d\u89e3\u6790\u5730\u5740\u4e3a\u672c\u673a\u5730\u5740\r\n\r\n[root@localhost named]# vim accp.com.zone \r\n\/\/\u7f16\u8f91accp\u57df\u540d\u533a\u57df\u6570\u636e\u914d\u7f6e\u6587\u4ef6\r\n$TTL 1D\r\n@ IN SOA @ rname.invalid. (\r\n 0 ; serial\r\n 1D ; refresh\r\n 1H ; retry\r\n 1W ; expire\r\n 3H ) ; minimum\r\n NS @\r\n A 127.0.0.1\r\nwww IN A 192.168.235.158\r\n##\u5220\u9664\u539f\u6765\u672b\u884c\u7684\u5185\u5bb9,\u6dfb\u52a0\u57df\u540d\u89e3\u6790\u5730\u5740\u4e3a\u672c\u673a\u5730\u5740\r\n\r\n[root@localhost named]# systemctl start named \r\n\/\/\u5f00\u542fdns\u670d\u52a1\r\n[root@localhost named]# systemctl stop firewalld.service \r\n\/\/\u5173\u95ed\u9632\u706b\u5899\r\n[root@localhost named]# setenforce 0 \r\n\/\/\u5173\u95ed\u589e\u5f3a\u578b\u5b89\u5168\u529f\u80fd<\/pre>\n1\u3001\u914d\u7f6e\u865a\u62df\u4e3b\u673a<\/strong>
2\u3001\u521b\u5efa\u81ea\u6d4b\u7f51\u9875<\/span><\/p>\n[root@localhost named]# cd \r\n[root@localhost ~]# mkdir -p \/var\/www\/html\/kgc\r\n[root@localhost ~]# mkdir -p \/var\/www\/html\/accp\r\n[root@localhost ~]# ls \/var\/www\/html\/\r\naccp kgc\r\n[root@localhost ~]# cd \/var\/www\/html\/\r\n[root@localhost html]# echo "this kgc web" > kgc\/index.html\r\n[root@localhost html]# echo "this accp web" > accp\/index.html<\/pre>\n3\u3001\u7f16\u8f91nginx.conf\u914d\u7f6e\u6587\u4ef6<\/span><\/p>\n[root@localhost html]# vim \/usr\/local\/nginx\/conf\/nginx.conf\r\n\r\nserver {\r\n listen 80;\r\n server_name www.kgc.com;\r\n\r\n charset utf-8;\r\n ##\u652f\u6301\u4e2d\u6587\u5b57\u7b26\r\n access_log logs\/www.kgc.com.access.log;\r\n ##kgc\u7ad9\u70b9\u8bbf\u95ee\u65e5\u5fd7\r\n location \/ {\r\n }\r\n error_page 500 502 503 504 \/50x.html;\r\n ##\u670d\u52a1\u7aef\u62a5\u9519\u76f8\u5173\u7f51\u9875\r\n location = \/50x.html {\r\n root html;\r\n }\r\n }\r\n\r\nserver {\r\n listen 80;\r\n server_name www.accp.com;\r\n\r\n charset utf-8;\r\n\r\n access_log logs\/www.accp.com.access.log;\r\n\r\n location \/ {\r\n root \/var\/www\/html\/accp;\r\n index index.html index.htm;\r\n }\r\n error_page 500 502 503 504 \/50x.html;\r\n location = \/50x.html {\r\n root html;\r\n }\r\n }<\/pre>\n4\u3001\u91cd\u8f7dNginx\u670d\u52a1<\/span><\/p>\n[root@localhost ~]# killall -s HUP nginx\r\n[root@localhost ~]# netstat -ntap | grep 80\r\ntcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 6117\/nginx: master<\/pre>\n5\u3001\u6d4b\u8bd5\u7f51\u9875,\u8f93\u5165www .kgc. com \u4e0e www. accp. com\u4e24\u4e2a\u57df\u540d\u8fdb\u884c\u8bbf\u95ee<\/span><\/p>\n<\/span><\/p>\n<\/span><\/p>\n<\/span><\/p>\n\u4e8c\u3001\u57fa\u4e8e\u7aef\u53e3<\/h3>\n
1\u3001\u914d\u7f6e\u865a\u62df\u4e3b\u673a<\/strong>
2\u3001\u521b\u5efa\u53e6\u4e00\u4e2a\u7aef\u53e3\u7684\u6d4b\u8bd5\u7f51\u9875<\/p>\n[root@localhost ~]# cd \/var\/www\/html\/\r\n[root@localhost html]# echo "this is kgc 8080 web" > kgc\/index.html<\/pre>\n3\u3001\u7f16\u8f91nginx.conf\u914d\u7f6e\u6587\u4ef6,\u4ec5\u4fee\u6539\u76d1\u542c\u5730\u5740<\/span><\/p>\n[root@localhost html]# vim \/usr\/local\/nginx\/conf\/nginx.conf\r\n\r\nserver {\r\n listen 192.168.235.158:80;\r\n ##\u76d1\u542c\u4e3b\u673a\u768480\u7aef\u53e3\r\n server_name www.kgc.com;\r\n\r\n charset utf-8;\r\n\r\n access_log logs\/www.kgc.com.access.log;\r\n\r\n location \/ {\r\n root \/var\/www\/html\/kgc;\r\n index index.html index.htm;\r\n }\r\n error_page 500 502 503 504 \/50x.html;\r\n location = \/50x.html {\r\n root html;\r\n }\r\n }\r\n\r\nserver {\r\n listen 192.168.235.158:8080;\r\n ##\u76d1\u542c\u4e3b\u673a\u76848080\u7aef\u53e3\r\n server_name www.kgc.com;\r\n\r\n charset utf-8;\r\n\r\n access_log logs\/www.kgc.com.access.log;\r\n\r\n location \/ {\r\n root \/var\/www\/html\/kgc;\r\n index index.html index.htm;\r\n }\r\n error_page 500 502 503 504 \/50x.html;\r\n location = \/50x.html {\r\n root html;\r\n }\r\n }<\/pre>\n
<\/span>4\u3001\u91cd\u8f7dNginx\u670d\u52a1<\/span><\/p>\n[root@localhost html]# killall -s HUP nginx\r\n[root@localhost html]# netstat -ntap | grep 80\r\ntcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 41958\/nginx: master<\/pre>\n<\/p>\n
\u4e09\u3001\u57fa\u4e8eIP<\/h3>\n
1\u3001\u6dfb\u52a0\u7f51\u5361,\u5e76\u89c4\u5212\u597dIP
\u4e3b\u673aIP :192.168.235.158 \uff1b 192.168.235.142
\u57df\u540d \uff1awww . kgc . com \uff1b www . accp . com<\/strong>
2\u3001\u4fee\u6539accp\u57df\u540d\u7684\u533a\u57df\u6570\u636e\u6587\u4ef6\u914d\u7f6e<\/p>\n[root@localhost ~]# vim \/var\/named\/accp.com.zone\r\n\r\n$TTL 1D\r\n@ IN SOA @ rname.invalid. (\r\n 0 ; serial\r\n 1D ; refresh\r\n 1H ; retry\r\n 1W ; expire\r\n 3H ) ; minimum\r\n NS @\r\n A 127.0.0.1\r\nwww IN A 192.168.235.142\r\n##\u66f4\u6539IP\u5730\u5740\u4e3a 192.168.235.142\r\n\r\n[root@localhost ~]# systemctl restart named\r\n##\u91cd\u542f\u57df\u540d\u89e3\u6790\u670d\u52a1<\/pre>\n3\u3001\u7f16\u8f91nginx.conf\u914d\u7f6e\u6587\u4ef6<\/span><\/p>\n[root@localhost ~]# vim \/usr\/local\/nginx\/conf\/nginx.conf\r\n##\u6b64\u6bb5\u4e0d\u505a\u4fee\u6539\r\nserver {\r\n listen 192.168.235.158:80;\r\n server_name www.kgc.com;\r\n\r\n charset utf-8;\r\n\r\n access_log logs\/www.kgc.com.access.log;\r\n\r\n location \/ {\r\n root \/var\/www\/html\/kgc;\r\n index index.html index.htm;\r\n }\r\n error_page 500 502 503 504 \/50x.html;\r\n location = \/50x.html {\r\n root html;\r\n }\r\n }\r\n\r\nserver {\r\n listen 192.168.235.142:80;\r\n ##\u4fee\u6539\u672c\u6bb5\u76d1\u542c\u5730\u5740\u4e3a192.168.234.142\r\n server_name www.accp.com;\r\n\r\n charset utf-8;\r\n\r\n access_log logs\/www.accp.com.access.log;\r\n\r\n location \/ {\r\n root \/var\/www\/html\/accp;\r\n index index.html index.htm;\r\n }\r\n error_page 500 502 503 504 \/50x.html;\r\n location = \/50x.html {\r\n root html;\r\n }\r\n }<\/pre>\n4\u3001\u91cd\u8f7dNginx\u670d\u52a1<\/span><\/p>\n[root@localhost ~]# killall -s HUP nginx\r\n[root@localhost ~]# netstat -ntap | grep 80\r\ntcp 0 0 192.168.235.142:80 0.0.0.0:* LISTEN 7299\/nginx: master \r\ntcp 0 0 192.168.235.158:80 0.0.0.0:* LISTEN 7299\/nginx: master<\/pre>\n5\u3001\u6d4b\u8bd5\u7f51\u9875,\u5206\u522b\u8f93\u5165IP\u5730\u5740192.168.235.158\u548c192.168.235.142\u8fdb\u884c\u8bbf\u95ee<\/span><\/p>\n<\/p>\n","protected":false},"excerpt":{"rendered":"
\u5982\u4f55\u642d\u5efanginx\u865a\u62df\u4e3b\u673a\uff1f\u8fd9\u4e2a\u95ee\u9898\u53ef\u80fd\u662f\u6211\u4eec\u65e5\u5e38\u5de5\u4f5c\u7ecf\u5e38\u89c1\u5230\u7684\u3002\u901a\u8fc7\u8fd9\u4e2a\u95ee\u9898\uff0c\u5e0c\u671b\u4f60\u80fd\u6536\u83b7\u66f4\u591a\u3002\u4e0b\u9762\u662f\u89e3\u51b3\u8fd9 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,95],"tags":[],"class_list":["post-1343","post","type-post","status-publish","format-standard","hentry","category-linux","category-nginx"],"_links":{"self":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts\/1343"}],"collection":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/comments?post=1343"}],"version-history":[{"count":1,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts\/1343\/revisions"}],"predecessor-version":[{"id":1344,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts\/1343\/revisions\/1344"}],"wp:attachment":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/media?parent=1343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/categories?post=1343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/tags?post=1343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}