一、基於寶塔配置文件分析(站的配置文件)
新增的站點配置即添加server並包含在nginx內
查找文件:
文件內容:
二、偽靜態
偽靜態是一種可以把文件后綴改成任何可能的一種方法,如果我想把php文件偽靜態成html文件。
該站點配置文件:
添加配置內容
如下:
其他偽靜態規則:
三、代理文件配置
配置文件如下:
其實就是nginx增加location段。
Nginx的HTTP配置主要包括三個區塊,結構如下:
Nginx的HTTP配置主要包括三個區塊,結構如下: http { //這個是協議級別 include mime.types; default_type application/octet-stream; keepalive_timeout 65; gzip on; server { //這個是服務器級別 listen 80; server_name localhost; location / { //這個是請求級別 root html; index index.html index.htm; } } }
location區段
通過指定模式來與客戶端請求的URI相匹配,基本語法如下:location [=|~|~*|^~|@] pattern{……}
1、沒有修飾符 表示:必須以指定模式開始,如:
server { server_name baidu.com; location /abc { …… } } 那么,如下是對的: http://baidu.com/abc http://baidu.com/abc?p1 http://baidu.com/abc/ http://baidu.com/abcde
2、=表示:必須與指定的模式精確匹配
server { server_name sish location = /abc { …… } } 那么,如下是對的: http://baidu.com/abc http://baidu.com/abc?p1 如下是錯的: http://baidu.com/abc/ http://baidu.com/abcde