build:添加docker文件

This commit is contained in:
2025-05-23 21:20:54 +08:00
parent b02a18d762
commit 9de698d90e
5 changed files with 365 additions and 0 deletions
+58
View File
@@ -0,0 +1,58 @@
# 定義一個 HTTP 服務器塊
server {
# 監聽 80 端口(HTTP
listen 80;
# 默認索引文件,按順序嘗試
index index.php index.html;
# 錯誤日誌和訪問日誌的路徑
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
# 網站根目錄,指向 Laravel 的 public 目錄
root /var/www/public;
# 客戶端上傳文件大小限制
client_max_body_size 100M;
# 處理所有請求
location / {
# 嘗試以 URI 作為文件查找,然後作為目錄,最後轉發到 index.php
try_files $uri $uri/ /index.php?$query_string;
# 啟用靜態 gzip 文件服務(如果存在 .gz 文件)
gzip_static on;
}
# 處理 PHP 文件請求
location ~ \.php$ {
# 如果文件不存在,返回 404
try_files $uri =404;
# 分割路徑信息,用於處理 PATH_INFO
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# 轉發 PHP 請求到 PHP-FPM 服務
fastcgi_pass app:9000;
# 設置 FastCGI 緩衝區大小
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
# 默認索引文件
fastcgi_index index.php;
# 設置 FastCGI 讀取超時時間(秒)
fastcgi_read_timeout 600;
# 包含 FastCGI 參數
include fastcgi_params;
# 設置 SCRIPT_FILENAME 參數,告訴 PHP-FPM 要執行的文件
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# 設置 PATH_INFO 參數,用於獲取路徑信息
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}