Nginx支持PHP的CI框架
1.找到CI库的配置文件修改
$config['base_url'] = 'http://test.example.com';
$config['uri_protocol'] = 'PATH_INFO';
2.找到NGINX配置.在SERVER段中添加如下代码段
location /index.php{
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_param SCRIPT_FILENAME /home/wwwroot/index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fcgi.conf;
}
3.如果要做跳转的话,(比如:http://test.example.com/index.php/test,跳转
http://test.example.com/test.)可以server 段中添加如下配置
location /{
if (-f $request_filename) {
expires max;
break;
}
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
}
}
*****************************************************************************
前一段时间为了 PATH_INFO 问题搞得郁闷,来回忆下原来的配置(以CodeIgniter框架的配置为例):
server {
listen 80;
server_name test.local;
location / {
root /www/test;
index index.html index.htm index.php;
rewrite ^/$ /index.php last;
rewrite ^/(?!index\.php|robots\.txt|images|js|styles)(.*)$ /index.php/$1 last;
}
location ~ \.php($|/) {
root /www/test;
set $script $uri;
set $path_info "";
if ($uri ~ "^(.+?\.php)(/.*)$") {
set $script $1;
set $path_info $2;
}
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $path_info;
fastcgi_pass unix:/tmp/php-fpm.sock;
include fastcgi_params;
}
}
虽然可以实现 PATH_INFO 了,但是还是有缺陷,URL 中的中文不会被 urldecode。
好在,0.7.31 版本以上的 Nginx 新增了fastcgi_split_path_info 这个指令,现在配置起来清晰多了:
server {
listen 80;
server_name test.local;
location / {
root /www/test;
index index.html index.htm index.php;
rewrite ^/$ /index.php last;
rewrite ^/(?!index\.php|robots\.txt|images|js|styles)(.*)$ /index.php/$1 last;
}
location ~ ^(.+\.php)(.*)$ {
root /www/test;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.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;
fastcgi_pass unix:/tmp/php-fpm.sock;
include fastcgi_params;
}
}
指令的具体帮助请参考官方WIKI:
http://wiki.nginx.org/NginxHttpFcgiModule#fastcgi_split_path_info
– EOF –
Nginx支持PHP的CI框架的更多相关文章
- centos nginx环境下删除CI框架Index.php入口遇到404问题
今天在网上百度看了很多文章,想要去掉index.php入口文件有好多方法,自己也照着在网站到根目录下新建了一个.htaccess文件,内容如下: RewriteEngine On RewriteCon ...
- Nginx 支持 CI 框架的配置并禁止使用 ip 访问
#CIserver { listen 80; server_name www.ci.com; index index.php index ...
- 在nginx下去掉ci框架url中的index.php
ci框架默认的url规则中带有应用的入口文件,例如: example.com/index.php/news/article/my_article 在以上URL中带有入口文件index.PHP,这样的U ...
- nginx location匹配顺序及CI框架的nginx配置
Nginx location匹配顺序如下: 用前缀字符串定义的location规则对URI进行匹配测试. =号定义了精确的前缀字符串匹配,如果发现精确匹配则使用当前规则.否则继续下一步匹配. 匹配其它 ...
- Nginx配置CI框架问题(Linux平台下Centos系统)
CI框架:官方文档 http://codeigniter.org.cn/user_guide/index.html CI框架的数据流程图如下: 其中:index.php作为入口文件,在安装好CI框架后 ...
- 配置nginx支持TP框架
TP框架配置中默认URL_MODEL=1,而Nginx默认是不支持PATHINFO的.如果我们只想跑起来tp框架,很简单,只需到更改TP配置,设置URL_MODEL=3(兼容模式).但是如果要让Ngi ...
- 如何让nginx支持ThinkPHP框架(重点参考)
公司有一款即将上线的应用服务端是基于ThinkPHP写的,本地测试无异常,上传到外网服务器后无法连接.这可把我和我的小伙伴们吓死了,怎么回事儿,本地测试都是对的呀! 我和我的小伙伴们开始找原因,换了一 ...
- ngnix 配置CI框架 与 CI的简单使用
ngnix 支持 CI框架1.修改config.php 参考网址:https://www.chenyudong.com/archives/codeigniter-in-nginx-and-url-re ...
- CI框架源码阅读笔记3 全局函数Common.php
从本篇开始,将深入CI框架的内部,一步步去探索这个框架的实现.结构和设计. Common.php文件定义了一系列的全局函数(一般来说,全局函数具有最高的加载优先权,因此大多数的框架中BootStrap ...
随机推荐
- maven---工程建立及目录添加--
刚开始建立maven工程目录1: 添加web能力: 选中工程鼠标右击点MyEclipse添加web能力: 然后: 关键点:remove掉Excluded:** 添加javaEE5库 确保web: 建p ...
- Ok6410裸机驱动学习(二)ARM基础知识
1.ARM工作模式 ARM微处理器支持7种工作模式,分别为: l 用户模式(usr):ARM处理器正常的程序执行状态(Linux用户态程序) l 快速中断模式(fiq):用于高速数据传输或通道处理 ...
- MySql集合查询
SELECT语句的查询结果是元组的集合,所以多个SELECT语句的结果可进行集合操作. 集合操作主要包括并操作UNION.交操作INTERSECT.差操作EXCEPT. 注意,参加集合操作的各查询结果 ...
- springboot thymeleaf org.xml.sax.SAXParseException错误
SpringBoot越来越受欢迎,而官方推荐的模板是thymeleaf ,但是其语法太过严格,使用过程中一不留心就会出现org.xml.sax.SAXParseException错误 其中主要是下面这 ...
- 22、IDP-ASE
IDPASE https://github.com/bdeonovic/IDPASE.jl Prepare necessary input files (1)FASTQ file of your hy ...
- get与post方法(吴老师整理)
Get方式:(用get方式请求时就是调用Servlet中的doGet方法) 1.第一种: 2.第二种:(<a>标签是一种get方式提交) 1.通过GET提交数据,用户名和密码将明文出现在U ...
- Linus与陈庆
Linus 1969年末,李纳斯出生于芬兰的赫尔辛基市,算是赶上了60后的尾巴.小时候他是个其貌不扬的孩子,除了一个鼻子长的「富丽堂皇」之外乏善可陈.他为了让鼻子看上去小一些,经常戴上眼镜就不愿意摘下 ...
- C#结构体指针的定义及使用详解(intptr的用法)
在解析C#结构体指针前,必须知道C#结构体是如何定义的.在c#中同样定义该结构体. C#结构体指针之C#结构体的定义: [StructLayout(LayoutKind.Sequential)] pu ...
- EasyUI知识点汇总
combobox联动设置 $(document).ready(function() { $('#gdfsdl1').combobox({ onSelect: function(record){ $(' ...
- OC官方文档翻译-Values-and-Collections-值与集合类型
查看全部文档翻译,请浏览https://github.com/L1l1thLY/Programming-with-Objective-C-in-Chinese,blog仅收录本人翻译的两章. 简述 O ...