首先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. Microsoft Internet Explorer v11 XML External Entity Injection 0day

    [+] Credits: John Page (aka hyp3rlinx) [+] Website: hyp3rlinx.altervista.org[+] Source:  http://hyp3 ...

  2. Python 多进程拷贝文件夹案例

    import os import multiprocessing def copy_file(q, file_name, old_folder_name, new_folder_name): &quo ...

  3. 脱壳系列—— *加密脱壳(Android使用手册破解)

    作者:i春秋作家HAI_ZHU 0×00 前言 好久没有写文了,要好好开动一下了.很多事情要忙.这篇文章本来很早之前就要写的,但是因为很多事情就拖了很久. 前置内容 HAI_使用手册 知识总结 0×0 ...

  4. ASE19团队项目 beta阶段 model组 scrum4 记录

    本次会议于12月5日,19时30分在微软北京西二号楼sky garden召开,持续10分钟. 与会人员:Lei Chai, Linfeng Qi, Xueqing Wu, Yutong Ling (Z ...

  5. Java 10 的 10 个新特性,你颤抖了吗?

    Java 9才发布几个月,很多玩意都没整明白,现在Java 10又快要来了.. 这时候我真尼玛想说:线上用的JDK 7 甚至JDK 6,JDK 8 还没用熟,JDK 9 才发布不久不知道啥玩意,JDK ...

  6. 09_Azkaban案例实践2_Command多job工作流flow

    1.Command类型多job工作流flow 1.创建有依赖关系的多个job描述:第一个job:foo.job # foo.job type=command command=echo foo 2.第二 ...

  7. idou老师带你认识Istio13:Istio实现基础认证策略

    前言 微服务架构提供了更好的灵活性.可伸缩性以及服务复用的能力,但,微服务也有特殊的安全需求,Istio Security尝试提供全面的安全解决方案.为了提供灵活的服务访问控制,需要双向 TLS 和细 ...

  8. web页面长时间未操作自动退出登录

    var lastTime = new Date().getTime(); var currentTime = new Date().getTime(); * * ; //设置超时时间: 10分 $(f ...

  9. 二进制学习——Blob,ArrayBuffer、File、FileReader和FormData的区别

    前言: Blob.ArrayBuffer.File.fileReader.formData这些名词总是经常看到,知道一点又好像不知道,像是同一个东西好像又不是,总是模模糊糊,最近终于下决心要弄清楚. ...

  10. vue中使用echarts画饼状图

    echarts的中文文档地址:https://echarts.baidu.com/tutorial.html#5%20%E5%88%86%E9%92%9F%E4%B8%8A%E6%89%8B%20EC ...