server { listen 80; server_name _; root /var/www/html/public; add_header X-Frame-Options "SAMEORIGIN"; add_header X-XSS-Protection "1; mode=block"; add_header X-Content-Type-Options "nosniff"; index index.php; charset utf-8; location / { index index.php; if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; break; } } location ~ \.php(/|$) { include fastcgi_params; #ubuntu 缺少这个配置 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; try_files $fastcgi_script_name =404; add_header logid $request_id; fastcgi_param logid $request_id; fastcgi_pass unix:/var/run/php-fpm.sock; fastcgi_index index.php; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } error_page 404 /index.php; location ~ /\.(?!well-known).* { deny all; } }