1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| server { listen 80; server_name site2.com www.site2.com; # 站点根目录 root /home/user/nginx/html/site2.com; index index.php index.html index.htm; # 访问日志 access_log /home/user/nginx/logs/site2.com/access.log; error_log /home/user/nginx/logs/site2.com/error.log; location / { try_files $uri $uri/ /index.php?$query_string; } # PHP 处理配置 location ~ \.php$ { # 根据您的 PHP-FPM 配置调整这里 # 如果是 Unix socket 方式 fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; #先运行php # 如果是 TCP 方式 # fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # 禁止访问隐藏文件 location ~ /\. { deny all; } }
|