1,摘要
2,內(nèi)容
2.1 如何服務(wù)器搭建網(wǎng)站(用寶塔面板)
請參考文章《如何服務(wù)器搭建網(wǎng)站(用寶塔面板)》 https://zhuanlan.zhihu.com/p/264988902
2.2 NGINX入門到精通系列
(1)【NGINX入門】1.Nginx基本介紹和安裝入門
http://www.lxweimin.com/p/dad9ffb77087
(2)【NGINX入門】2.Nginx搭建靜態(tài)資源web服務(wù)器
http://www.lxweimin.com/p/862fb0fedc76
(3)【NGINX入門】3.Nginx的緩存服務(wù)器proxy_cache配置
http://www.lxweimin.com/p/6045923457dd
(4)【NGINX入門】4.Nginx location 匹配規(guī)則詳細解說[+正則表達式]
http://www.lxweimin.com/p/d576ee70ba8e
(5)【NGINX入門】5.Nginx實現(xiàn)負載均衡的6種方式及配置
http://www.lxweimin.com/p/d42d66644ef8
(6)【NGINX入門】6.Nginx的rewrite規(guī)則詳解
http://www.lxweimin.com/p/899e6883db59
(7)【NGINX入門】7.Nginx配置安全證書SSL實例
http://www.lxweimin.com/p/f0e7bad52d93
(8)【NGINX入門】8.Nginx的upstream 模塊及參數(shù)測試
http://www.lxweimin.com/p/fe310776be7c
(9)【NGINX入門】9.Nginx負載均衡并實現(xiàn)session共享的方法和實踐
http://www.lxweimin.com/p/f30d50a82860
(10)【NGINX入門】10.Nginx代理smtp、pop等郵件服務(wù)
http://www.lxweimin.com/p/629ef7246ce2
(11)【NGINX入門】11.Nginx限流算法及配置實踐
http://www.lxweimin.com/p/93e2790a6817
(12) 【NGINX入門】12.OpenResty(Nginx+Lua)高并發(fā)最佳實踐
http://www.lxweimin.com/p/3924118ce79a
(13) 【NGINX入門】13.Nginx日志詳解
http://www.lxweimin.com/p/bf8aeeb0335a
(14) 【NGINX入門】14.Nginx原理深度解析
http://www.lxweimin.com/p/e5ceb4c69fc4
(15)【NGINX入門】15.史上最全Nginx面試題
http://www.lxweimin.com/p/8abf5bfbbceb
(16)【NGINX入門】16.使用JMeter壓力測試工具測試NGINX限流配置實踐
http://www.lxweimin.com/p/e813d71bd9a4
2.3 語法補充
2.3.1 error_page語法
語法:
error_page code [ code... ] [ = | =answer-code ] uri | @named_location
默認值:
no
使用字段:
http, server, location, location 中的if字段
舉例:
nginx指令error_page的作用是當(dāng)發(fā)生錯誤的時候能夠顯示一個預(yù)定義的uri,比如:
error_page 502 503 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
當(dāng)error_page后面跟的不是一個靜態(tài)的內(nèi)容的話,比如是由proxyed server或者FastCGI/uwsgi/SCGI server處理的話,server返回的狀態(tài)(200, 302, 401 或者 404)也能返回給用戶。
error_page 404 = /404.php;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
也可以設(shè)置一個named location,然后在里邊做對應(yīng)的處理。
error_page 500 502 503 504 @jump_to_error;
location @jump_to_error {
proxy_pass http://backend;
}
同時也能夠通過使客戶端進行302、301等重定向的方式處理錯誤頁面,默認狀態(tài)碼為302。
error_page 403 http://example.com/forbidden.html;
error_page 404 =301 http://example.com/notfound.html;
同時error_page在一次請求中只能響應(yīng)一次,對應(yīng)的nginx有另外一個配置可以控制這個選項:recursive_error_pages
默認為false,作用是控制error_page能否在一次請求中觸發(fā)多次。
2.3.2 try_files的語法
try_files是nginx中http_core核心模塊所帶的指令,主要是能替代一些rewrite的指令,提高解析效率。
格式1:
try_files file ... uri; 格式2:try_files file ... =code;
使用字段:
可應(yīng)用的上下文:server,location段
使用說明:
關(guān)鍵點1:按指定的file順序查找存在的文件,并使用第一個找到的文件進行請求處理
關(guān)鍵點2:查找路徑是按照給定的root或alias為根路徑來查找的
關(guān)鍵點3:如果給出的file都沒有匹配到,則重新請求最后一個參數(shù)給定的uri,就是新的location匹配
關(guān)鍵點4:如果是格式2,如果最后一個參數(shù)是 = 404 ,若給出的file都沒有匹配到,則最后返回404的響應(yīng)碼
舉例說明1:
location /images/ {
root /opt/html/;
try_files $uri $uri/ /images/default.gif;
}
比如 請求 127.0.0.1/images/test.gif 會依次查找:
1.文件/opt/html/images/test.gif
2.文件夾 /opt/html/images/test.gif/下的index文件
3.請求127.0.0.1/images/default.gif
注釋:
try-files 如果不寫上 $uri/,當(dāng)直接訪問一個目錄路徑時,并不會去匹配目錄下的索引頁 即 訪問127.0.0.1/images/ 不會去訪問 127.0.0.1/images/index.html 。
舉例說明2:
location / {
try_files /system/maintenance.html
$uri $uri/index.html $uri.html
@mongrel;
}
location @mongrel {
proxy_pass http://mongrel;
}
以上中若未找到給定順序的文件,則將會交給location @mongrel處理(相當(dāng)于匹配到了@mongrel來匹配)。
3,問題解答
(1)寶塔忘記登錄密碼 紫框即你要修改的密碼,紅框即面板賬戶
實際操作:
cd /www/server/panel && python tools.py panel testpasswd
nqo5l7ns
cd /www/server/panel && python tools.py panel admin
nqo5l7ns
所以重置的用戶名/密碼為nqo5ldns/admin
4,參考
(1)寶塔官網(wǎng) https://www.bt.cn/
(2)如何服務(wù)器搭建網(wǎng)站(用寶塔面板)
https://zhuanlan.zhihu.com/p/264988902
(3) 開源建站W(wǎng)ordPress
https://cn.wordpress.org/
(4)Nginx實戰(zhàn)教程
https://blog.csdn.net/junyouyh/category_8906485.html