···
server {
listen 80; // 监听80端口, 默认站点
#listen [::]:80 default_server; // // IPV6 开启
root /var/www/html; // 配置网站站点目录
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name localhost; // 域名
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
#try_files $uri $uri/ =404; //首页访问规则
// 记得修改
try_files $uri $uri/ /index.php?$query_string;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
// 开启这块注释,解析php文件
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php7.0-cgi alone:
// 两种方式 : 1.监听 9000 端口, 2.sock 链接, 推荐使用 1
fastcgi_pass 127.0.0.1:9000;
# # With php7.0-fpm:
# fastcgi_pass unix:/run/php/php7.0-fpm.sock;
} //注意闭合哦!
}
···
群主,这是我nginx的基本配置,您发的配置内容我看了下,有些位置的作用,不是很明白?
特别这一段
···
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php7.1-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
···