架构总览与前置准备
应用层高可用部署
server {
listen 80;
server_name your_domain.com;
root /var/www/your_project/public;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php/php7.4-fpm.sock; # 或 127.0.0.1:9000
}
location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg|woff2)$ {
expires 30d;
access_log off;
}
location ~ /\.env { deny all; }
location ~ /(app|config|database|route|runtime|vendor)/ { deny all; }
error_log /var/log/nginxphp_error.log;
access_log /var/log/nginxphp_access.log;
}
多实例时,各节点保持相同 Nginx/ThinkPHP 配置与代码版本,仅调整 fastcgi_pass 指向本机 PHP-FPM。数据与缓存高可用
负载均衡与健康检查
发布运维与监控