开始接触NGINX,配置tp5配了半天,找不到具体原因,于是用网上搜索到的配置复制粘贴搞定。

感谢 https://blog.csdn.net/qq_36431213/article/details/80456993

开始以为是rewrite部分写不正确,其实根本就不用if(!-e $request_name){ rewrite ^(.*)$ /index.php/$ last;break;},

用 try_files $uri $uri/ index.php?$request_string;就可以,傻傻折腾了半天,要不得!!!

详看附件

  • 下面开始上配置
    server {
listen 80; #端口
server_name localhost; #主机名
set $root /usr/share/nginx/html/tp5/public/; #文件入口
index index.php; error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
#静态资源
location ~ .*\.(gif|jpg|jpeg|bmp|png|ico|txt|js|css)$
{
root /usr/share/nginx/html;
} location ~ \.css {
add_header Content-Type text/css;
} location ~ \.js {
add_header Content-Type application/x-javascript;
}
#php请求
location / {
include /etc/nginx/mime.types
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
root $root;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $request_uri; include fastcgi_params;
} #
location ~ /\.ht {
deny all;
}
}

或者

server {
listen 80;
server_name localhost; #charset koi8-r;
#access_log /var/log/nginx/host.access.log main; location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
root /usr/share/nginx/html/tp5/public/;
index index.php;
} #error_page 404 /404.html; # redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /usr/share/nginx/html/tp5/public/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}

nginx 1.14.0 配置部署 thinkphp 5.1的更多相关文章

  1. centos 7.2 下 nginx 1.14.1 安装部署

    Nginx1.14.1安装部署 1.环境: 所有源码在跳板机kx的/web/soft下 2.安装依赖: [root@bogon src]# yum install -y libxml2 openssl ...

  2. CentOS 7.4安装Nginx 1.14.0

    一.安装所需环境   1.gcc 安装         yum install gcc-c++    

  3. nginx HTTP/2.0 配置

    1.前言 最近无意中看到http2.0消息,发现自己的博客虽然配了https,但并没有配置http2.0,所以搞了个玩玩,本以为配个参数就搞定了,结果还是折腾了一个小时. 2.过程 nginx并没有默 ...

  4. Centos 7 编译nginx 1.14.0

    步骤一:下载nginx安装包 wget https://nginx.org/download/nginx-1.14.0.tar.gz 步骤二:安装nginx依赖包 yum install -y gcc ...

  5. kubenetes_V1.14.0 安装部署

    k8s的安装有多种方式,如yum安装,kubeadm安装,kubemini安装,二进制安装(生产环境多采用此方式精确控制安装)等.本文是入门系列验证,之前进行过yum安装,可以查看文章<k8s入 ...

  6. Centos7 编译安装 Nginx Mariadb Asp.net Core2 (实测 笔记 Centos 7.3 + Openssl 1.1.0h + Mariadb 10.3.7 + Nginx 1.14.0 + Asp.net. Core 2 )

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7-x86_64-Minimal-1611.iso 安装步骤: 1.准备 1.0 查看硬 ...

  7. Nginx HA 及https配置部署

    Nginx HA 整体方案架构为: (内网192.168.199.5) +-----------VIP----------+ | | | | Master Backup 192.168.199.90 ...

  8. Nginx安装负载均衡配置 fair check扩展

    前言 本文主要是针对Nginx安装.负载均衡配置,以及fair智能选举.check后端节点检查扩展功能如何扩展,进行讲解说明. fair模块: upstream-fair,“公平的”Nginx 负载均 ...

  9. Ubuntu 16.04 安装最新稳定版Nginx 1.6.0

    Ubuntu 16.04 默认安装的是nginx 1.14.0 #默认安装方式:apt-get  install nginx   1.查看是否安装nginx,如果已经安装,请先卸载 #查看安装版本 d ...

随机推荐

  1. SpringMVC(二)高级

    高级参数绑定 1.1. 绑定数组 1.1.1. 需求 在商品列表页面选中多个商品,然后删除. 1.1.2. 需求分析 功能要求商品列表页面中的每个商品前有一个checkbok,选中多个商品后点击删除按 ...

  2. linux面试题(自己添加了一些注释说明)

    1.linux如何挂在windows下的共享目录 首先需要在Windows中创建一个文件夹用来共享,例如下面就是server是用来共享的,貌似在哪个位置创建都可以,我是在d盘创建的 1 mount.c ...

  3. Java中的继承抽象类和接口

    一.总结 1.使用extends关键字继承,eg: class Student extends Persion { ...}; 2.Java编程规范中类的首字母大写,方法的首字母小写单词首字母代谢,e ...

  4. java保留2位小数及BigDecimal使用

    java保留两位小数的方法 import java.math.BigDecimal; import java.text.DecimalFormat; import java.text.NumberFo ...

  5. Primitives vs Objects

    这里首先我们要了解什么是primitives 和 objects 其实理解起来很简单. 如果我们懂.NET开发就会知道C#中的值类型和引用类型. primitives variables contai ...

  6. 适配器(Adapter)

    Adapter:将一个Class的接口转换成另一个Class的接口,使原本因接口不兼容而不能合作的Class可以一起运作.主要有两种:迭代器适配器(Iterator Adpater)和容器适配器(Co ...

  7. C# ASCII与字符串间相互转换 (转)

    引言: 最近开始学习C#,在写串口助手小工具时遇到十六进制发送与字符发送之间转换的问题, 小弟通过网络各路大神的帮助下,终于实现正确显示收发,小弟菜鸟一枚,不足之处还望各位批评指正O(∩_∩)O! 其 ...

  8. Hanlp在ubuntu中的使用方法介绍

    HanLP的一个很大的好处是离线开源工具包,换而言之,它不仅提供免费的代码免费下载,而且将辛苦收集的词典也对外公开啦,此诚乃一大无私之举.我在安装的时候,主要参照这份博客: blog.csdn.net ...

  9. diff命令详解

    Linux diff命令 Linux diff命令用于比较文件的差异. diff以逐行的方式,比较文本文件的异同处.如果指定要比较目录,则diff会比较目录中相同文件名的文件,但不会比较其中子目录 用 ...

  10. App音频内录 录音

    1.android模拟器 天天模拟器+BlueStacks 2.高清内录软件 Audio Record Wizard.exe 3.音频剪切软件 Adobe Audition CS6