很久不使用apache了,渐渐对apache感到陌生,因为朋友有个ZendFramework框架从apache移到nginx下,需要pathinfo模式支持。
网上海搜
于是开始搜索nginx+pathinfo相关文章,一开以为很容易就会配置好。因为搜索后发现有大量文章介绍nginx开启pathinfo模式,感觉不是什么难事。但是经过几个小时下来,还是没有配置好。并且大量文章的内容都极其相似,基本都是转载的。
开始有点急了!因为一天过去了没有配好。
继续摸索
没办法,继续搜索。为了验证方便,我用a.com下载thinkphp框架搭了个环境。并且加了UserAction.class.php控制器类,在类里加了一个app方法并输出一行文字。
于是,我开始不断地改写nginx.conf文件重启nginx,不断的刷新a.com/index.php/User/app 地址。结果要么是地址损坏提示、502、Access defind.
又是一天过去了,开始感觉有点彷徨。
最后坚持
按理说我感觉应该有nginx+thinkphp的先例,只是我没有搜索到答案而已。突然间感觉网上好迷茫,一个小小的问题寻求不到解答。今晚,又试着使用nginx thinkphp关键字搜索,我一下点到十多页以后,找到一处代码
location / {
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
} location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
} 保存修改,重启nginx,刷新浏览器
意想不到的页面出现了 居然能访问了,终于松了一口气,实在太不容易了。
贴出nginx.conf代码
user www www; worker_processes 2;
worker_cpu_affinity 01 10; error_log /data1/logs/nginx_error.log crit; pid /usr/local/webserver/nginx/nginx.pid; worker_rlimit_nofile 65535; events
{
use epoll;
worker_connections 65535;
} http
{
include mime.types;
default_type application/octet-stream; server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m; sendfile on;
tcp_nopush on; keepalive_timeout 60;
tcp_nodelay on; fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k; server
{
listen 80;
server_name a.com;
index index.php;
root /data0/htdocs/a.com/www; location / {
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
} location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
}
}
}

nginx支持pathinfo模式的更多相关文章

  1. 使nginx支持pathinfo模式

    在将fastadmin部署到虚拟机中时,遇到如下问题:当访问登录页面时,页面进行不断的循环跳转重定向.解决方法是将nginx配置为支持pathinfo的模式 以下是nginx中的配置内容: locat ...

  2. 配置Nginx支持pathinfo模式

    Nginx服务器默认不支持pathinfo, 在需要pathinfo支持的程序中(如thinkphp),则无法支持”/index.php/Home/Index/index”这种网址.网上流传的解决办法 ...

  3. nginx低版本不支持pathinfo模式,thinkphp针对此问题的解决办法

    将一个thinkphp项目从apache环境移到nginx1.2上,怎奈,nginx这个版本默认不支持pathinfo模式 首先,编辑nginx的虚拟主机配置文件 location ~ .*.(php ...

  4. 使得nginx支持pathinfo访问模式

    原理:     任意创建一个 in.php 文件:             <?php                       echo '<pre>';             ...

  5. 配置nginx支持path_info模式

    简介:我们用thinkphp,CodeIgniter框架的时候,地址基本都是IP/index.php/group_controller?***的模式,通过index.php入口访问php文件 这种模式 ...

  6. 修改两行代码,让nginx支持phpinfo模式

    Nginx服务器默认不支持pathinfo, 在需要pathinfo支持的程序中(如thinkphp),则无法支持”/index.php/Home/Index/index”这种网址. 网上流传的解决办 ...

  7. nginx支持pathinfo并且隐藏index.php

    How To Set Nginx Support PATHINFO URL Model And Hide The /index.php/ 就像这样 The URL before setting lik ...

  8. centOS7.4 thinkPHP nginx 支持pathinfo和rewrite

    server { listen 80; server_name www.demo.com mayifanx.com; root /data/www/demo; index index.php inde ...

  9. 让Nginx支持pathinfo

    # 典型配置 location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_ ...

随机推荐

  1. @RequestMapping定义不同的处理器映射规则

    通过@RequestMapping注解可以定义不同的处理器映射规则. 1. URL路径映射 @RequestMapping(value="item")或@RequestMappin ...

  2. mdf 与 mdb的对比

    下面的内容从网上搜索而来,未经过本人严格验证,仅供参考. 1.问:mdb数据库能否脱离Access运行?即,没有安装Access,可以打开mdb吗? 答:可以,脱离Access运行,可以到微软的同类产 ...

  3. android基本控件学习-----RadioButton&CheckBox

    RadioButton(单选框)和CheckBox(复选框)讲解: 一.基本用法和事件处理 (1)RadioButton单选框,就是只能选择其中的一个,我们在使用的时候需要将RadioButton放到 ...

  4. python --- comment

    single line comment : multiple line comment :

  5. C#反射(Reflection)详解

    1. 什么是反射2. 命名空间与装配件的关系3. 运行期得到类型信息有什么用4. 如何使用反射获取类型5. 如何根据类型来动态创建对象6. 如何获取方法以及动态调用方法7. 动态创建委托 1.什么是反 ...

  6. AC日记——集合位置 洛谷 P1491

    集合位置 思路: 次短路: 先走一遍最短路: 记录最短路径,然后依次删边走最短路: 最短的长度就是次短路: 来,上代码: #include <queue> #include <cma ...

  7. Codeforces 482B Interesting Array(线段树区间更新)

    题目链接 Interesting Array 区间更新.然后对于每一个约数重新求一遍区间的&值,不符合就跳出. #include <bits/stdc++.h> using nam ...

  8. Codeforces 371E Subway Innovation (前缀和预处理应用)

    题目链接 Subway Innovation 首先不难想到所求的k个点一定是连续的,那么假设先选最前面的k个点,然后在O(1)内判断第2个点到第k+1个点这k个点哪个更优. 判断的时候用detla[i ...

  9. schema设计

    Schema设计   Schema:表的模式:   设计数据的表,索引,以及表和表的关系 在数据建模的基础上将关系模型转为数据库表 满足业务模型需要基础上根据数据库和应用特点优化表结构   关系模型图 ...

  10. String、Stringbuffer和Stringbuilder之间的区别

    关于这三个类在字符串处理中的位置不言而喻,那么他们到底有什么优缺点,到底什么时候该用谁呢?下面我们从以下几点说明一下 1.在执行速度方面:Stringbuilder>Stringbuffer&g ...