您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

让nginx圆满支持Thinkphp的配置

2025/11/20 12:07:00发布16次查看
让nginx完美支持thinkphp的配置
习惯了用apache后,当第一次用nginx时,把原来的项目(thinkphp框架)部署在新服务器上的时候,惊呆了!
所有的url模式下都不能正常运行,甚至连css,js文件都不能正常加载。
原因是ngibx不支持pathinfo
主要是需要配置nginx
location / { root d:/wnmp/www; index index.html index.htm; #访问路径的文件不存在则重写url转交给thinkphp处理 if ( !-e $request_filename ) { rewrite ^/(.*)$ /index.php/$1 last; break; } }
location ~ \.php/?.*$ { root        d:/wnmp/www; fastcgi_pass   127.0.0.1:9001; fastcgi_index  index.php; #加载nginx默认服务器环境变量配置 include        fastcgi_params; include   fastcgi.conf; #设置path_info并改写script_filename,script_name服务器环境变量 set $fastcgi_script_name2 $fastcgi_script_name; if ( $fastcgi_script_name ~ ^(.+\.php)(/.+)$ ) { set $fastcgi_script_name2 $1; set $path_info $2; } fastcgi_param   path_info $path_info; fastcgi_param   script_filename   $document_root$fastcgi_script_name2; fastcgi_param   script_name   $fastcgi_script_name2; }
最后这部分是为了css和js 以及图片等资源
location ~* ^.+\.(jpg|jpeg|gif|png|bmp|css|js|swf)$ { access_log off; root d:/wnmp/www; break; }
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product