server {
# 監聽 HTTP 協議默認的 [80] 端口。
listen 80;
# 綁定主機名 [example.com]。
server_name example.com;
# 服務器站點根目錄 [/example.com/public]。
root /example.com/public;
# 添加幾條有關安全的響應頭;與 Google+ 的配置類似,詳情參見文末。
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
# 站點默認頁面;可指定多個,將順序查找。
# 例如,訪問 http://example.com/ Nginx 將首先嘗試「站點根目錄/index.html」是否存在,不存在則繼續嘗試「站點根目錄/index.htm」,以此類推...
index index.html index.htm index.php;
# 指定字符集為 UTF-8
charset utf-8;
# Laravel 默認重寫規則;刪除將導致 Laravel 路由失效且 Nginx 響應 404。
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# 關閉 [/favicon.ico] 和 [/robots.txt] 的訪問日志。
# 并且即使它們不存在,也不寫入錯誤日志。
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
# 將 [404] 錯誤交給 [/index.php] 處理,表示由 Laravel 渲染美觀的錯誤頁面。
error_page 404 /index.php;
# URI 符合正則表達式 [\.php$] 的請求將進入此段配置
location ~ \.php$ {
# 配置 FastCGI 服務地址,可以為 IP:端口,也可以為 Unix socket。
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
# 配置 FastCGI 的主頁為 index.php。
fastcgi_index index.php;
# 配置 FastCGI 參數 SCRIPT_FILENAME 為 $realpath_root$fastcgi_script_name。
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
# 引用更多默認的 FastCGI 參數。
include fastcgi_params;
}
# 通俗地說,以上配置將所有 URI 以 .php 結尾的請求,全部交給 PHP-FPM 處理。
# 除符合正則表達式 [/\.(?!well-known).*] 之外的 URI,全部拒絕訪問
# 也就是說,拒絕公開以 [.] 開頭的目錄,[.well-known] 除外
location ~ /\.(?!well-known).* {
deny all;
}
}
- 前言
- php
- 設計模式
- 代碼安全
- 性能測試
- 自動化測試
- 項目質量
- 自動化部署
- 掌握框架
- laravel5.8
- laravel聲明周期
- mysql
- 物理文件組成
- 存儲引擎和優化
- 權限和安全
- 備份和恢復
- 查詢優化
- 索引優化
- 主從架構
- 監測工具
- redis
- redis簡介
- redis存儲
- windows下 php7.3+redis3 安裝
- 參數配置說明
- redis 數據類型
- 緩存穿透和緩存雪崩問題
- redis并發競爭key問題
- thinkphp5+redis+mysql搶票示例
- apache
- nginx
- Nginx服務器的安裝部署
- Nginx服務器架構
- Nginx服務器的高級配置
- Nginx服務器的Rewrite功能
- Nginx服務器的代理服務
- Nginx服務器的緩存機制
- Nginx源碼結構
- Nginx基本數據結構
- 微服務
- 分布式
- 前后端分離解決方案
- 服務端實現
- thinkphp5
- laravel5
- 客戶端實現H5
- vue.js
- element-ui
- vue-cli
- 客戶端APP
- 客戶端小程序
- 代碼自動生成
- 商城項目實戰
- 系統架構