首先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. windows找不到头文件的问题

    windows系统中,设置好了环境变量,就可以在cmd下直接执行文件,但是 特别是在c语言或者c++程序中,include头文件的问题,如果找不到,就考虑是不是文件放错地方了. windows上编译c ...

  2. c#重写了窗体的OnKeyDown事件,但是不执行

    设置下窗体的KeyPreview属性值为True即可 总结:遇到类似这样的问题,比如其他窗体运行没问题,就新建的窗体有问题.应该检查下窗体的属性.

  3. leetcode-100. Same Tree · Tree + DFS + Queue

    题面 对比两棵二叉树是否相同,返回结果. 思路 1. 递归解决DFS 首先判断根节点,如果都空,返回true: 如果一空一不空,返回false: 如果都不空,判断两节点值是否相同,若不同,返回fals ...

  4. JS 百度地图 地图线路描绘

    JS 百度地图 地图线路描绘 <script type="text/javascript" src="http://api.map.baidu.com/api?v= ...

  5. PP 各种快捷键

    内容识别 Shitf + F5 (留白填充) 内容识别比例 Alt + Shift +Ctrl +C 取消选区 Ctrl + D Alpha通道 左击 + Ctrl 锐化 先换成Lab颜色 在无颜色的 ...

  6. NLP学习(2)----文本分类模型

    实战:https://github.com/jiangxinyang227/NLP-Project 一.简介: 1.传统的文本分类方法:[人工特征工程+浅层分类模型] (1)文本预处理: ①(中文) ...

  7. Oracle查看数据占用的空间和数据文件实际空间的信息

    可以使用如下sql: select 'bgdrac' database,t11.username,t11.default_tablespace tablespace_name,segment_size ...

  8. MySQL进阶2 sql选择语句 where

    与SQL语句一致 #进阶2: 条件查询 /* 语法 select 查询列表 #3 from 表名 #1 where 筛选条件; #2 分类: 1.按条件表达式进行筛选 > < = != & ...

  9. javascript如何处理字符串中的\u

    问题: 字符串在页面显示的时候,有\u,如:Tesla\u8fc1\u79fb ,想要显示它的原文 let a = 'Tesla\u8fc1\u79fb' //显示 Tesla迁移 alert( un ...

  10. SVN安装与汉化

    官网地址:http://tortoisesvn.net/downloads.html 如地址过期可自行百度官网,下载安装包安装64/32位 如果需要汉化的同学,同样在下载页面,往下拉Language ...