Nginx部署Thinkphp 404错误PathInfo的解决方案
2016-05-10 17:30
691 查看
之前没有在意一直都是在Apache下部署,换成Nginx折腾了半天。终于搞定。
# # The default server # server { listen 80; server_name ** location / { root /www/; index index.php index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ \.php { #去掉后面的$ root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(.*)$; #增加这一句 fastcgi_param PATH_INFO $fastcgi_path_info; #还有这一句 #fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME /site/www.xxr.so/$fastcgi_script_name; # 这个是在配置nginx+php整合的时候就改好的$前面的是网站的主目录 include fastcgi_params; } }最后,不要忘了在 php.ini 中将 cgi.fix_pathinfo=0 改为1nginx 1.6.2 和上面的稍有不同。
server { listen 80; server_name meiman.com ; root "E:/www/ymems"; location / { index index.html index.htm index.php; #autoindex on;
##增加下面的内容if (!-e $request_filename) {rewrite ^/(.*)$ /index.php/$1 last;}}location ~ \.php(.*)$ {fastcgi_pass 127.0.0.1:9000;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;fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;include fastcgi_params;}}今天换了个环境,发现用上面的方法不管用。在网上找了试试这个管用。另外也许有的不在根目录,参考下面的。
location / {if (!-e $request_filename) {###一级目录下rewrite ^/(.*)$ /index.php/$1 last;###域名下的二级目录#rewrite ^/目录名/(.*)$ /目录名/index.php/$1 last;}}
相关文章推荐
- 配置Nginx+PHP的正确思路与过程
- Nginx + CGI/FastCGI + C/Cpp
- nginx 并发数问题思考:worker_connections,worker_processes与 max clients
- nginx虚拟主机配置
- 使用nginx支持utf8中文
- nginx安装详解
- Nginx 获取真实 IP 方案
- ubunt,cent OS安装配置Nginx
- 阿里云Nginx绑定多个域名的方法
- LNMP(linux+nginx+mysql+php)服务器环境配置
- ubuntu安装nginx
- 用于wordpress站点的nginx服务器配置(PHP)
- PHP7+Nginx的配置与安装教程详解
- Nginx(PHP/fastcgi)的PATH_INFO问题
- Nginx 502gateway错误故障解决
- nginx下 499错误
- PHP7+Nginx的配置与安装教程详解
- 配置Nginx+PHP的正确思路与过程
- CentOS 6.5 yum 安装nginx
- #内存管理的艺术# 之 Nginx slab的实现 --- 第一篇“基本布局”