在我的本地计算机上,official laravel documentation
的nginx配置不起作用server {
listen 80;
server_name example.com;
root /example.com/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
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 ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
但它适用于几行的变化
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
更改为
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
一切正常。任何人都可以解释一下这段代码的不同之处并且它是不安全的吗?
答案 0 :(得分:0)
只有合理的差异,我才会看到包含文件:snippets/fastcgi-php.conf
和fastcgi_params
只需添加以下内容即可修复您的问题:
fastcgi_param SCRIPT_FILENAME $request_filename;
到/etc/nginx/fastcgi_params
档。
在旧版本的nginx中存在该行。
但是从1.10.x
它被删除并成为空白屏幕的原因。