一、系统环境
1.ngix1.14.2
2.PHP7.2.12
3.ThinkPHP5.1:下载到d:/php/www目录
二、PHP.ini
doc_root = "d:/php/www"
cgi.force_redirect = 0
cgi.fix_pathinfo=1
三、ngix.conf
server {
listen 80;
server_name localhost;
set $root D:/PHP/WWW;
charset utf-8;
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
#access_log logs/host.access.log main;
#php请求
location / {
root $root;
index index.html index.htm index.php ;
#如果文件不存在则尝试TP解析
#try_files $uri /index.php$uri;
try_files $uri $uri/ /index.php?s=$uri&$args;
}
location ~ .+\.php($|/) {
root $root;
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$; #增加这一句
fastcgi_param PATH_INFO $fastcgi_path_info; #增加这一句
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# proxy the
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
root $root;
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
}