首先tp5的访问目录指向到webroot/public文件夹中。
thinkphp的url访问:http://serverName/index.php(或者其它应用入口文件)/模块/控制器/操作/[参数名/参数值...],这个需要支持pathinfo,Apache默认支持,而Nginx不支持。
1.php.ini中的配置参数cgi.fix_pathinfo = 1
2.修改nginx.conf文件。

  1. location ~ \.php(.*)$ {
  2. fastcgi_pass   127.0.0.1:9000;
  3. fastcgi_index  index.php;
  4. #下面两句是给fastcgi权限,可以支持 ?s=/module/controller/action的url访问模式
  5. fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
  6.             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
  7. #下面两句才能真正支持 index.php/index/index/index的pathinfo模式
  8. fastcgi_param  PATH_INFO  $fastcgi_path_info;
  9.             fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
  10. include        fastcgi_params;
  11. }
复制代码

这样就能在linux,nginx环境下运行tp5了。

3. 去掉/index.php/
修改nginx.conf文件

    1. location / {
    2. index  index.html index.htm index.php;
    3. #autoindex  on;
    4. if (!-e $request_filename) {
    5. rewrite  ^(.*)$  /index.php?s=/$1  last;
    6. break;
    7. }
    8. }

nginx - nginx下配置thinkphp5的更多相关文章

  1. nginx环境下配置nagios-关于nagios配置文件nginx.conf

    接上文:nginx环境下配置nagios-关于nginx.conf 配置如下: ;          location ~ .*\.(php|php5)?$          {            ...

  2. nginx环境下配置nagiosQL-关于nagiosql配置文件

    接上文:nginx环境下配置nagios-关于nginx.conf nagiosql文件应该处于conf/domain/目录下 nagiosql配置如下: ;                  gzi ...

  3. Nginx环境下配置PHP使用的SSL认证(https)

    最近一段时间发现好多网站都从http协议变成了加密的https协议,比如说百度.吾志等等.https看起来比http高端了好多,而且在不同的浏览器向上还会显示出不同于http的URL展示效果(比如说c ...

  4. <nginx+PHP>nginx环境下配置支持php7

    [root@redhat7 ~]# wget http://am1.php.net/get/php-7.1.2.tar.gz/from/this/mirror [root@redhat7 ~]# ta ...

  5. nginx环境下配置nagios-关于start_perl_cgi.sh

    >/dev/ rm $dir/logs/perl-fcgi.sock >/dev/ echo  }    start ()  {  rm $dir/now_start_perl_fcgi. ...

  6. nginx环境下配置nagios-关于perl-fcgi.pl

    配置文件如下: 请注意,网上提供的官方文档在运行时可能会出现问题,此文中保证无问题. ; ; ; ;  ); ;  ); ; ;          my $pidnumber = $$;        ...

  7. phpmyadmin在nginx环境下配置错误

    location ~ \.css {           add_header  Content-Type    text/css;        } location ~ \.js {        ...

  8. 在phpstudy集成环境下的nginx服务器下配置url重写

    直接在对应的vhosts.conf配置文件的location / {}中添加以下内容: location / { index index.html index.htm index.php; #auto ...

  9. nginx环境下配置nagios-关于commands.cfg

    -w $ARG1$ -c $ARG2$ -M -b% -c % -f% -c % -f% -c % -f #  define command{         command_name    chec ...

随机推荐

  1. 案例:selenium实现登录百度(如有验证码,需要手动输入)

    func.py https://www.cnblogs.com/andy9468/p/10899508.html baidu_login.py中(如有验证码,需要手动输入) # 导入webdriver ...

  2. 02 WIndows编程——危险的sizeof

    C语言中,对 sizeof() 的处理都是在编译阶段进行. 下面代码,注意可变参数是怎么使用的 #include<Windows.h> #include<stdio.h> in ...

  3. Oracle 安装步骤

    目录 Oracle 安装步骤 一.安装流程 二.登录流程 三.新建数据库 四.图形化连接 Oracle 安装步骤 一.安装流程 解压oracle 11g两个压缩文件 点击安装,修改目录,新建一个文件夹 ...

  4. NLP学习(3)---Bert模型

    一.BERT模型: 前提:Seq2Seq模型 前提:transformer模型 bert实战教程1 使用BERT生成句向量,BERT做文本分类.文本相似度计算 bert中文分类实践 用bert做中文命 ...

  5. python c++ 混合编程中python调用c++string返回类型的函数,python中返回为数字的解决办法

    本随笔解决 Python使用ctypes 调用c++dll 字符串返回类型函数,在python中显示为数字:原文解决方案见so: https://stackoverflow.com/questions ...

  6. python学习之文件读写,序列化(json,pickle,shelve)

    python基础 文件读写 凡是读写文件,所有格式类型都是字符串形式传输 只读模式(默认) r  f=open('a.txt','r')#文件不存在会报错 print(f.read())#获取到文件所 ...

  7. spring实例化二:SimpleInstantiationStrategy

            spring对类的实例化,定义了接口InstantiationStrategy,同时先做了个简单实现类SimpleInstantiationStrategy.采用实现部分,抽象部分的策 ...

  8. java基础:多态过程中的动态绑定

    重刷java-core的chapter05,P158 重读多态,感觉又不一样了. 记录一下对象方法执行过程: 1.  编译器查看对象声明类型和方法名,如class.fuction(param),cla ...

  9. 【翻译】PATH究竟是什么?

    最近,我试图向一个朋友解释他电脑上PATH变量是用来做什么的.我在我们所交流的平台‘the Slack group"写了一篇比较长的消息之后,我意识到这个主题可以写成一个很好的博客,所以开始 ...

  10. BZOJ 1778: [Usaco2010 Hol]Dotp 驱逐猪猡 (高斯消元)

    题面 题目传送门 分析 令爆炸概率为PPP.设 f(i)=∑k=0∞pk(i)\large f(i)=\sum_{k=0}^{\infty}p_k(i)f(i)=∑k=0∞​pk​(i),pk(i)p ...