nginx自定義站點目錄及簡單編寫開發網頁內容講解
阿新 • • 發佈:2017-08-20
linux
[[email protected] conf]# egrep -v "^$|#" nginx.conf.default >nginx.conf
[[email protected] conf]# pwd
/application/nginx/conf
[[email protected] conf]# vim nginx.conf 1 worker_processes 1; 2 events { 3 worker_connections 1024; 4 } 5 http { 6 include mime.types; 7 default_type application/octet-stream; 8 sendfile on; 9 keepalive_timeout 65; 10 server { 11 listen 80; 12 server_name localhost; 13 location / { 14 root html; 15 index index.html index.htm; 16 } 17 error_page 500 502 503 504 /50x.html; 18 location = /50x.html { 19 root html; 20 } 21 } 22 }
把第12行修改為如下:
12 server_name www.etiantian.org;
優雅重啟/application/nginx/sbin/nginx -s reload
[[email protected] conf]# /application/nginx/sbin/nginx -t nginx: the configuration file /application/nginx-1.6.3//conf/nginx.conf syntax is ok nginx: configuration file /application/nginx-1.6.3//conf/nginx.conf test is successful [[email protected] conf]# /application/nginx/sbin/nginx -s reload
[[email protected] conf]# cd /application/nginx/html/ [[email protected] html]# ls 50x.html index.html [[email protected] html]# rm -f index.html
編輯index.html文件,輸入如下內容:
[[email protected] html]# vim index.html
<html> <head> <title>老男孩教育運維28期</title> </head> <body> 28期最牛 <table border=1> <tr> <td>學號</td> <td>姓名</td> </tr> <tr> <td>01</td> <td>力哥</td> </tr> <tr> <td>02</td> <td>亮哥</td> </tr> </table> <a href="http://blog.oldboyedu.com"target=_balcnk><img src="gongli.jpg"冰冰美女</a> </body> </html>
然後再到當前目錄上傳一張gongli.jpg的圖片(圖片在下面附件中)。rz -y回車上傳
</html>[[email protected] html]# pwd /application/nginx/html [[email protected] html]# ls 50x.html gongli.jpg index.html
最後打開windows ie輸入地址http://10.0.0.8/ 即可打開網址。首頁站點部署成功。
打開windows C:\Windows\System32\drivers\etc\hosts文件添加本地DNS解析
10.0.0.8 www.etiantian.org
cmd 中ping www.etiantian.org查看解析是不是10.0.0.8ip地址,如果是直接在ie中打開網址www.etiantian.org即可。
C:\Users\Administrator>ping www.etiantian.org 正在 Ping www.etiantian.org [10.0.0.8] 具有 32 字節的數據: 來自 10.0.0.8 的回復: 字節=32 時間<1ms TTL=64 來自 10.0.0.8 的回復: 字節=32 時間<1ms TTL=64 來自 10.0.0.8 的回復: 字節=32 時間<1ms TTL=64 來自 10.0.0.8 的回復: 字節=32 時間<1ms TTL=64 10.0.0.8 的 Ping 統計信息: 數據包: 已發送 = 4,已接收 = 4,丟失 = 0 (0% 丟失), 往返行程的估計時間(以毫秒為單位): 最短 = 0ms,最長 = 0ms,平均 = 0ms
本文出自 “sandshell” 博客,請務必保留此出處http://sandshell.blog.51cto.com/9055959/1957666
nginx自定義站點目錄及簡單編寫開發網頁內容講解