首页 > 系统相关 >nginx与php pathinfo(TP5框架适用)

nginx与php pathinfo(TP5框架适用)

时间:2024-02-22 11:14:13浏览次数:28  
标签:index pathinfo nginx TP5 location php fastcgi

最近在试用fastadmin这一个框架,是由tp5进行二开后的一款框架。fastadmin里面有个代码,要获取pathinfo否则会重定向到登录页,而默认的nginx配置获取的pathinfo一直为空,就导致无法正常进入后台。

通过查找资料后,发现pathinfo是php的产物,与nginx无关。如果要让nginx把pathinfo环境变量传到php,需如下设置:

  server {
    listen 80;
    server_name _;
    access_log /data/wwwlogs/access_nginx.log combined;
    root /mnt/hgfs/vm_virtual_path/fastadmin/public;
    index index.html index.htm index.php;
    #error_page 404 /404.html;
    #error_page 502 /502.html;


    location / { 
       if (!-e $request_filename) { 
           rewrite  ^(.*)$  /index.php?s=/$1  last; 
       } 
    } 

    location /nginx_status {
      stub_status on;
      access_log off;
      allow 127.0.0.1;
      deny all;
    }
    location ~ [^/]\.php(/|$) {
      set $script $uri;
      set $path_info "";
 
      if ($uri ~ "^(.+.php)(/.+)") {
        set $script $1;
        set $path_info $2;
      }

      #fastcgi_pass remote_php_ip:9000;
      fastcgi_pass unix:/dev/shm/php-cgi.sock;
      fastcgi_index index.php;
      include fastcgi.conf;

      fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name; 
      fastcgi_param  PATH_INFO  $path_info; 
      #fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info; 

    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
      expires 30d;
      access_log off;
    }
    location ~ .*\.(js|css)?$ {
      expires 7d;
      access_log off;
    }
    location ~ ^/(\.user.ini|\.ht|\.git|\.svn|\.project|LICENSE|README.md) {
      deny all;
    }
    location /.well-known {
      allow all;
    }
  }

 

标签:index,pathinfo,nginx,TP5,location,php,fastcgi
From: https://www.cnblogs.com/ddcoder/p/18026880

相关文章

  • nginx日志切割备份
    直接上脚本#!/bin/bash#源日志目录logs_path="/logs/nginx"#备份日志目录back_logs_path="${logs_path}/backup/$(date-d'yesterday'+'%F')"#创建备份目录,以日期命名,注意,每天零点整切割,开始记录新的一天的日志,备份目录应该是昨天mkdir-p${back_logs_path}#重命......
  • Nginx之SSI
    一、简介    SSI【ServerSideInclde】。基于服务端的网页制作技术,即服务端包含。该项目中用到了Nginx中的SSI模块的include命令,这个命令会包含一个页面,然后在nginx服务器中展开。二、使用    2.1、开启SSI        Linux路径地址为:   ......
  • nginx的安装(文心一言)
    在Ubuntu中安装Nginx可以通过APT包管理器进行。以下是在Ubuntu中安装Nginx的步骤:1.更新软件包列表:首先,打开终端并更新您的软件包列表,以确保您安装的是最新的软件包。sudoaptupdate2.安装Nginx:接下来,使用APT包管理器安装Nginx。sudoaptinstallnginx安装过程中,您可能会被提......
  • 自己新写的软件, 使用nginx反向代理
    windows版本安装包: https://nginx.org/en/download.html   nginx用于代理服务器,常用于负载均衡等,可以实现用户请求转发。 在python中,为了提高程序的并发性能,使其能够满足更高的访问量,一般会利用多进程以及协程,对程序进行改造。但是服务在启动的时候,随之确定的也就......
  • Nginx 配置限流
    Nginx配置限流1概述2限制请求速率2.1、正常限流2.2、处理突发流量2.3、设置白名单2.4、limit_req重复3限制连接数4上传/下载速率限制4.1、limit_rate4.2、limit_rate_after4.3、proxy_limit_rate4.4、动态限速4.2、基于变量动态限速1概述限流(RateLimitt......
  • Linux服务器配置nginx访问静态网页
    配置nginx 打开conf文件进行编辑:sudonano/etc/nginx/nginx.conf在http块内添加:server{listen80;server_namexxx.your_domain.com;root/root/work/your_web_folder;indexindex.html;}重启nginx:sudoservicenginxrestart如果......
  • Mac安装Nginx
    Nginx安装#查找nginx版本brewsearchnginx#安装nginx,默认是最新版本brewinstallnginx#指定版本安装方式为:nginx@版本号[email protected]#卸载nginxbrewuninstallnginxbrewuninstallnginx@版本号#查看已安装的软件brewlist#查看nginx安装信息(eg:......
  • [转帖]nginx利用request_body记录POST body(location中用proxy_pass)
    https://www.cnblogs.com/freedom-try/p/14699538.html1.完整过程1.1在nginx.conf中http里面添加配置如下:http{ ... log_formatpostdataescape=json'$remote_addr-$remote_user[$time_local]"$request" '$status$bod......
  • Linux 安装 Nginx
    一、步骤    1、配置EPEL源   sudoyuminstall-yepel-releasesudoyum-yupdate    2、安装Nginxsudoyuminstall-ynginx     安装成功后,默认网站目录为:/usr/share/nginx/html     默认的配置文件为:/etc/nginx/nginx.conf......
  • Nginx 生产环境下的安全配置
    Nginx生产环境下的安全配置Linux就该这么学 2024-02-0908:02 北京 2人听过链接:https://blog.51cto.com/u_14249042/7633794 Nginx简介    Nginx是开源、高性能、高可靠的Web和反向代理服务器,而且支持热部署,几乎可以做到7*24小时不间断运行,即使运......