Ngx學習搭建和配置
阿新 • • 發佈:2018-12-11
發現沒有像網上很多資料那樣,再etc下面生成了/sites-available/dotcom這樣的目錄,也無法使用 ln -s /etc/nginx/sites-available/dotcom /etc/nginx/sites-enabled/dotcom 將他們進行連線。 尋找到自己伺服器上的ngx 再home/ubantu/nginx-1.15.3/目錄下 配置檔案在 home/ubantu/nginx-1.15.3/conf/nginx.conf下 在server中,配舍自己搭建的域名 server{ … listen 80; //監聽埠號,網際網路的預設埠是80 server_name xxxx.com ; //自己的域名 root /xxx/xxx/xxx ; //定義檔案放置的路徑 … } 從官方文件中,獲取的程式碼示例:
location = / {
[ configuration A ]
}
location / {
[ configuration B ]
}
location /documents/ {
[ configuration C ]
}
location ^~ /images/ {
[ configuration D ]
}
location ~* \.(gif|jpg|jpeg)$ {
[ configuration E ]
}
The “/” request will match configuration A, the “/index.html” request will match configuration B, the “/documents/document.html” request will match configuration C, the “/images/1.gif” request will match configuration D, and the “/documents/1.jpg” request will match configuration E.
Location接受兩個引數,一個字串或者正則和一段程式碼。