序言
目录结构
1.D盘下建立PHP目录
2.PHP目录里有nginx-1.17.8、php-7.4.2与WWW 这三个目录
一、nginx.conf配置
server {
listen 80;
server_name localhost;
set $root D:/PHP/WWW;
charset utf-8;
#access_log logs/host.access.log main;
location / {
root $root;
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}
location ~ \.php$ { #*********去掉.php右边的$,否则不好用 *******************
root $root;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $root$fastcgi_script_name;
#下面两句是给fastcgi权限,可以支持 ?s=/module/controller/action的url访问模式
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $root$fastcgi_script_name;
#下面两句才能真正支持 index.php/index/index/index的pathinfo模式
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $root$fastcgi_path_info;
include fastcgi_params;
}
二、PHP.ini 配置
extension_dir = "D:\PHP\php-7.4.2\ext"
enable_dl = On
cgi.force_redirect = 0
cgi.fix_pathinfo = 1
extension=mbstring
extension=openssl
extension=pdo_mysql
fastcgi.impersonate = 1
cgi.rfc2616_headers = 1
date.timezone = Asia/Shanghai
三、Start.bat
D:\PHP\RunHiddenConsole D:\PHP\nginx-1.17.8\nginx.exe -p D:\PHP\nginx-1.17.8
D:\PHP\RunHiddenConsole D:\PHP\php-7.4.2\php-cgi.exe -b 127.0.0.1:9000-c D:\PHP\php-7.4.2\php.ini
注:如果运行显示乱码的话,用以下命令试试
chcp 65001 就是换成UTF-8
chcp 936 可以换回默认的GBK
chcp 437 是美国英语
四、ThinkPHP
应用根目录下的.example.env 文件重命名为.env文件