nginx支持pathinfo模式
很久不使用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模式的更多相关文章
- 使nginx支持pathinfo模式
在将fastadmin部署到虚拟机中时,遇到如下问题:当访问登录页面时,页面进行不断的循环跳转重定向.解决方法是将nginx配置为支持pathinfo的模式 以下是nginx中的配置内容: locat ...
- 配置Nginx支持pathinfo模式
Nginx服务器默认不支持pathinfo, 在需要pathinfo支持的程序中(如thinkphp),则无法支持”/index.php/Home/Index/index”这种网址.网上流传的解决办法 ...
- nginx低版本不支持pathinfo模式,thinkphp针对此问题的解决办法
将一个thinkphp项目从apache环境移到nginx1.2上,怎奈,nginx这个版本默认不支持pathinfo模式 首先,编辑nginx的虚拟主机配置文件 location ~ .*.(php ...
- 使得nginx支持pathinfo访问模式
原理: 任意创建一个 in.php 文件: <?php echo '<pre>'; ...
- 配置nginx支持path_info模式
简介:我们用thinkphp,CodeIgniter框架的时候,地址基本都是IP/index.php/group_controller?***的模式,通过index.php入口访问php文件 这种模式 ...
- 修改两行代码,让nginx支持phpinfo模式
Nginx服务器默认不支持pathinfo, 在需要pathinfo支持的程序中(如thinkphp),则无法支持”/index.php/Home/Index/index”这种网址. 网上流传的解决办 ...
- nginx支持pathinfo并且隐藏index.php
How To Set Nginx Support PATHINFO URL Model And Hide The /index.php/ 就像这样 The URL before setting lik ...
- centOS7.4 thinkPHP nginx 支持pathinfo和rewrite
server { listen 80; server_name www.demo.com mayifanx.com; root /data/www/demo; index index.php inde ...
- 让Nginx支持pathinfo
# 典型配置 location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_ ...
随机推荐
- bzoj 1228 [SDOI2009]E&D SG函数打表 找规律
题目链接 Description 桌子上有2n 堆石子,编号为1..2n.将第2k-1 堆与第2k 堆(1 ≤ k ≤ n)为同一组.第i堆的石子个数用一个正整数Si表示.一次分割操作指的是,从桌子上 ...
- mysql5.7 mysql库下面的user表没有password字段无法修改密码
如题所述,mysql5.7 mysql库下面的user表没有password字段无法修改密码, 5.7版本已经不再使用password来作为密码的字段了 而改成了authentication_st ...
- AC日记——石子归并 51nod 1021
石子归并 思路: 经典动态规划——归并类问题: 我们把状态划为n个,即1-n的n个长度为n个状态: 那么,每个长度为i的状态都可以由i-1个长度为i-1的状态推出: 所以,dp转移方程: dp[i][ ...
- 误加all_load引起的程序报错
一.为什么要加-all_load 在64位的mac系统和iOS系统下,链接器有一个bug,会导致只包含有类别的静态库无法使用-ObjC标志来加载文件.解决方法是使用-all_load或者-force_ ...
- TP5 多条件whereOr查询
问题背景:最近在用ThinkPHP 5开发项目的过程中,发现根据筛选条件做or查询的时候,连贯操作不可以使用where进行条件查询了. 首先列出一个user数据表的信息: uid uname grad ...
- Centos python 2.6 升级到 2.7
前几天做了下阿里云的RDS日志相关功能,其工具大都是Python语言编写,但服务器初始化时的Python版本又不满足需求,本身也没有学过Python,因此在问题定位上费了一番周折,最后找朋友帮忙看了下 ...
- 页面css代码
博主原来的页面css代码 (这个是原来的那种效果,差不多弄出来会是这种效果http://www.cnblogs.com/thmyl/) /*simplememory*/ #google_ad_c1, ...
- 10.1综合强化刷题 Day3
括号序列(bracket) Time Limit:1000ms Memory Limit:128MB 题目描述 LYK有一个括号序列,但这个序列不一定合法. 一个合法的括号序列如下: ()是合法的 ...
- 维生素d
作者:卓正内科李爽 链接:https://www.guokr.com/article/440438/来源:果壳本文版权属于果壳网(guokr.com),禁止转载.如有需要,请联系sns@guokr.c ...
- JAVA基础之List接口
个人理解: list接口是Collection接口的子类,其继承了Collection接口的所有方法,但也有其独有的方法,不过在迭代的时候不要进行任何操作.牢记数据存储的四种结构:堆栈.队列.数组.链 ...