thinkphp5的 nginx 配置,官方文档参考: http://static.kancloud.cn/manual/thinkphp5/177576
fastadmin的 nginx 配置,官方文档参考:https://doc.fastadmin.net/doc/faq.html
server { listen 80; server_name www.fa.com *.fa.com; root "C:/phpstudy/WWW/fastadmin/public"; location / { index index.html index.htm index.php; #主要是这一段一定要确保存在 if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; break; } #结束 #autoindex on; } location ~ .php(.*)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^((?U).+.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; } }
使用MAMP PRO配置的时候, 可以将location /规则添加到nginx的第一个文本框。
#主要是这一段一定要确保存在 if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; break; }
第二段location是匹配的伪静态规则,需要修改对应的nginx配置。
如果直接添加到nginx配置界面的server部分,则会被追加到末尾,这就造成该规则不起作用。
这里的server 额外添加的规则应该是解析静态资源目录的规则,如下:
location @rewrite { set $static 0; if ($uri ~ .(css|js|jpg|jpeg|png|gif|ico|woff|eot|svg|css.map|min.map|mp3|wav|m4a)$) { set $static 1; } if ($static = 0) { rewrite ^/(.*)$ /index.php?s=/$1; } }
下面才是真正修改伪静态规则的方法:
打开MAMP PRO ,菜单栏的 File -> Edit Template -> nginx, 修改大约196行开始,注释掉原来的 php解析规则,更改为:
location ~ .php(.*)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^((?U).+.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; }
保存,并重启nginx即可生效。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 字符编码:从基础到乱码解决
2014-12-18 PowerShell连接中国Azure
2014-12-18 使用 Windows PowerShell 来管理和开发 windowsazure.cn 账户的特别注意事项