CentOS7 nginx简单配置pathinfo模式(ThinkPHP)

  1. location ~ \.php {    #去掉$
  2. root          H:/PHPServer/WWW;
  3. fastcgi_pass   127.0.0.1:9000;
  4. fastcgi_index  index.php;
  5. fastcgi_split_path_info ^(.+\.php)(.*)$;     #增加这一句
  6. fastcgi_param PATH_INFO $fastcgi_path_info;    #增加这一句
  7. fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
  8. include        fastcgi_params;
  9. }
时间: 2024-08-24 21:57:50

CentOS7 nginx简单配置pathinfo模式(ThinkPHP)的相关文章

nginx中配置pathinfo模式示例

要想让nginx支持PATH_INFO,首先需要知道什么是pathinfo,为什么要用pathinfo? pathinfo不是nginx的功能,pathinfo是php的功能. php中有两个pathinfo,一个是环境变量$_SERVER['PATH_INFO']:另一个是pathinfo函数,pathinfo() 函数以数组的形式返回文件路径的信息;. nginx能做的只是对$_SERVER['PATH_INFO]值的设置. 下面我们举例说明比较直观.先说php中两种pathinfo的作用,

NGINX关于配置PATHINFO

最近在群里发现有很多小白不会配置pathinfo现贴出来配置代码照着配置就可以了 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 server { listen       80; server_name xxx.com root      /alidata1/wwwroot/xxx; index  index.html index.htm index.php; //这里是关键 location ~ \.php { fast

Yii2.0配置pathinfo模式

原始访问模式为:http://www.month9bk.com/index.php?r=user/lists 那么想要改成全是/的pathinfo模式我们需要进行以下配置: 1.打开config文件夹下的main.php输入以下代码: 'urlManager' => [ //设置pathinfo模式 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => [ ], ], 此代码的位置为: 2.省略掉index

nginx下开启pathinfo模式

第一种方式是通过重写url来实现pathinfo模式: 1 location / { 2 if (!-e $request_filename){ 3 rewrite ^/(.*)$ /index.php?s=/$1 last; 4 } 5 } 第二种方式 ,改变 \.php的 1 location ~ \.php { 2 #fastcgi_pass 127.0.0.1:9000; 3 #fastcgi_pass unix:/dev/shm/php-cgi.sock; 4 fastcgi_pass

Nginx下实现pathinfo及ThinkPHP的URL Rewrite模式支持

打开Nginx的配置文件 /usr/local/nginx/conf/nginx.conf 一般是在这个路径,根据你的安装路径可能有所变化.如果你配置了vhost,而且只需要你这一个vhost支持pathinfo的话,可以直接打开你的vhost的配置文件.找到类似如下代码(不同版本的nginx可能稍有不同,但是相差不会很远): location ~ .*.(php|php5)?$ { #原有代码 } 修改成以下代码: #去掉$是为了不匹配行末,即可以匹配.php/,以实现pathinfo #如果

lnmp配置pathinfo模式

LNMP 配置支持 pathinfo 此文章来自 乌龟运维 wuguiyunwei.com 1,nginx里添加以下配置文件内容如下 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

nginx不支持pathinfo模式解决方法

错误描述:1,打开网页,页面提示不支持pathinfo                  2,类似 index.php/hellworld 会提示找不到页面 解决办法:1,修改nginx.conf的server{} 中的内容下: 备注: 如果是在vhost配置下可单独添加在vhost配置文件下,如果没有vhost则在nginx.conf配置文件下添加 75         # pass the PHP scripts to FastCGI server listening on 127.0.0.

nginx不支持pathinfo 导致thinkphp出错解决办法

location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; } } 然后项目配置下url模式改为2 'URL_MODEL'=>2, location ~ \.php { #去掉$ root H:/PHPServer/WWW; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^(.

Nginx简单配置,部分来源于网络

nginx.conf listener监听端口 server_name监听域名 location{}是用来为匹配的 URI 进行配置,URI 即语法中的“/uri/”.location  / { }匹配任何查询,因为所有请求都以 / 开头. root指定对应uri的资源查找路径,这里html为相对路径,完整路径为/opt/ opt/nginx-1.7.7/html/ worker_connections表示每个工作进程的最大连接数 server{}块定义了虚拟主机 index指定首页index文