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_ ...
随机推荐
- 网页内容切换效果实现的15个jQuery插件
原文发布时间为:2010-02-01 -- 来源于本人的百度文章 [由搬家工具导入] http://www.webjx.com/javascript/jsajax-15550.html
- DataGrid关键字变色
原文发布时间为:2009-05-01 -- 来源于本人的百度文章 [由搬家工具导入] private void DataGrid1_ItemDataBound(object sender, ...
- web.config add handlers and httpmodule to System.Web section.
<?xml version="1.0" encoding="utf-8"?> <!-- For more information on how ...
- eclipse在linux下无故闪退解决
A fatal error has been detected by the Java Runtime Environment: SIGSEGV (0xb) at pc=0x00007f25d0b92 ...
- AI创投的冰与火之歌:泡沫、跟风、短板和有钱花不出去的沮丧【转】
转自:http://36kr.com/p/5071386.html 国内的AI行业仍处于野蛮生长阶段.热钱不少,优质项目却不多.创业者拿钱难,投资者有钱却花不出去. 编者按:本文来自微信公众号“刺猬公 ...
- linux内核情景分析之信号实现
信号在进程间通信是异步的,每个进程的task_struct结构有一个sig指针,指向一个signal_struct结构 定义如下 struct signal_struct { atomic_t cou ...
- HDU5032 Always Cook Mushroom(树状数组&&离线)
树状数组+询问离线.一个优化是需要的,就是先对1000*1000个点先排序,而不是每次都生成这1000*1000个点然后和询问一起排序,那样会tle. #include <iostream> ...
- 设置自定义Dialog背景不变暗
设置Dialog弹窗的背景不变暗,有两种方式,一种是通过在style中设置,一种是通过代码设置. 一.在style中设置 <style name="dialog_waiting&quo ...
- Codeforces 371D Vessels (模拟)
题目链接 Vessels 这道题我做得有点稀里糊涂啊==TLE了几发之后改了一行就A了. 具体思路就是记fi为若第i个容器已经盛不下水了,那么接下来盛水的那个容器. hi为若现在要给i号容器加水,当前 ...
- 转:GEF 英文全称Graphical Editor Framework
http://blog.csdn.net/chancein007/article/category/2713827