首先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. Oracle查看表之间的约束

    ----查看表约束 表格: user_constraints 查询外键约束条件 select ' select count(*) from '||TABLE_NAME||';'from user_co ...

  2. Vs2017 FrameWork EF Mysql Mvc 三层整合1

    1  运行环境   vs2017   Net FromWork 4.6.2  手动版 没有 ado.net 实体数据模型 2 NuGet  MySql.Data.Entity 6.10.9, MySq ...

  3. python之列表、元组

    Day 2-Morning 创建列表 创建列表和创建普通变量一样,用中括号括起一堆数据即可(这里的数据可以是整型.字符串.浮点型...甚至可以包含另一个列表),数据间用逗号隔开. eg:number= ...

  4. sh make.sh fatal error: opencv2/opencv.hpp: No such file or directory

    问题: sh make.sh fatal error: opencv2/opencv.hpp: No such file or directory 解决: sudo apt-get install l ...

  5. Spark(三)角色和搭建

    目录 Spark(三)角色和搭建 一.Spark集群角色介绍 二.集群的搭建 三.history服务 四.使用spark-submit进行计算Pi 五.Spark On Yarn 六.shell脚本 ...

  6. python3 准备

    一.前言 1.Python是著名的“龟叔”Guido van Rossum发明的 2.python分为python2和python3两大版本,python2渐渐被淘汰,建议使用python3 3.py ...

  7. PHP json_encode转换 不对url进行解析

    echo json_encode($array,JSON_UNESCAPED_SLASHES);

  8. 微信PC版Hook研究思维导图

  9. Nginx中ngx_http_proxy_module模块

    该模块允许将请求传递给另⼀一台服务器器指令:1 ,proxy_pass设置代理理服务器器的协议和地址以及应映射位置的可选 URI .作为协议,可以指定“ http 或 https .可以将地址指定为域 ...

  10. 2018VUE面试题总结

      Vue面试题 一:什么是MVVM MVVM是是Model-View-ViewModel的缩写,Model代表数据模型,定义数据操作的业务逻辑,View代表视图层,负责将数据模型渲染到页面上,Vie ...