如何在win 客戶端通過在瀏覽器中輸入域名訪問服務(wù)器呢?
worker_processes 1;events { worker_connections 1024;}http { server_names_hash_bucket_size 128; include mime.types; default_type application/octet-stream; sendfile on; } server { listen 80; server_name www.banwago.com; location / { root html/www; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
創(chuàng)建域名對(duì)應(yīng)的站點(diǎn)目錄及文件
[root@pdm1-centos6 ~]# mkdir /application/nginx/html/www -p[root@pdm1-centos6 ~]# echo "http://www.banwago.com" >/application/nginx/html/www/index.html[root@pdm1-centos6 ~]# cat /application/nginx/html/www/index.html http://www.banwago.com
[root@pdm1-centos6 ~]# /application/nginx/sbin/nginx -tnginx: the configuration file /application/nginx-1.6.3//conf/nginx.conf syntax is oknginx: configuration file /application/nginx-1.6.3//conf/nginx.conf test is successful
[root@pdm1-centos6 ~]# /application/nginx/sbin/nginx -s reload## 啟動(dòng)Nginx [root@pdm1-centos6 ~]# /application/nginx/sbin/nginx## 如果沒有啟動(dòng)Nginx 則無法reload
[root@pdm1-centos6 ~]# ps -ef|grep nginxroot 1162 1 0 10:09 ? 00:00:00 nginx: master process ../sbin/nginxnginx 1216 1162 0 10:39 ? 00:00:00 nginx: worker processroot 1225 1128 0 10:43 pts/0 00:00:00 grep nginx[root@pdm1-centos6 ~]# netstat -lntp|grep 80tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1162/nginx
[root@pdm1-centos6 ~]# echo "10.0.0.200 www.banwago.com" >>/etc/hosts[root@pdm1-centos6 ~]# tail -l /etc/hosts10.0.0.200 www.banwago.com[root@pdm1-centos6 ~]# curl www.banwago.comhttp://www.banwago.com
提示:不要忘記在訪問的客戶端做hosts 解析,Linux 或者windows 都需要做hosts 解析。
hosts 解析:在C:\Windows\System32\drivers\etc這個(gè)路徑下找到hosts 文件,想辦法在后面追加10.0.0.200 www.banwago.com。如果有權(quán)限的問題,把文件復(fù)制到桌面,修改好了之后再?gòu)?fù)制回來,這個(gè)文件是沒有后綴的。如果需要添加多個(gè)域名,在后面空格添加就行了。
配置好之后可以在dos 里ping 一下該域名。
C:\Users\Administrator>ping www.banwago.com正在 Ping www.banwago.com [10.0.0.200] 具有 32 字節(jié)的數(shù)據(jù):來自 10.0.0.200 的回復(fù): 字節(jié)=32 時(shí)間=535ms TTL=64
最后在瀏覽器中輸入http://www.banwago.com/ ,能訪問到如下頁(yè)面表示一切正常。
聯(lián)系客服