开始接触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. MogileFS-2.44 安装与配置

    MogileFS-2.44 安装与配置 (转:https://my.oschina.net/u/1259000/blog/182277) 目录 一.MogileFS 介绍 1.1.环境 二.Mogil ...

  2. MySQL Partition--分区基础

    ================================================================================= Mysql在5.1版本时增加对分区表 ...

  3. springboot收藏的博客

    1.纯洁的微笑:http://www.ityouknow.com/ 2.嘟嘟独立博客:http://tengj.top/ 3.http://blog.didispace.com/

  4. UWA 技术分享连载 转载

    技术分享连载1 Q1:Texture占用内存总是双倍,这个是我们自己的问题,还是Unity引擎的机制? Q2:我现在发现两个因素直接影响Overhead,一个是Shader的复杂度,一个是空Updat ...

  5. 主机-配件-接口-整机-3c-1

    standby 待机 hibernate 休眠(睡眠) power-off 关机 usb端口能给外部设备充电在低压状态(standby,hibernate,power-off),如果系统运行在batt ...

  6. KiCad 的 Digikey 元件库

    KiCad 的 Digikey 元件库 KiCad 最初由法国人Jean-Pierre Charras于1992年推出,目前由 CERN(欧洲核子研究组织)接手开发. 而且现在有很多大公司的加入,比如 ...

  7. Eclipse之父、《设计模式》作者、Junit作者之Erich Gamma

    Erich Gamma拥有多重权威身份.他是Jazz项目的主要领导人:是Eclipse的项目管理委员会成员,被业界称为“Eclipse之父”: 是经典书<设计模式>的作者四人帮之一,199 ...

  8. webpack 提取 manifest 文件

    当 webpack 生成 bundle 时, 它同时维护一个 manifest 文件.你可以在生成的 vendor bundle 中找到它.manifest 文件描述了哪些文件需要 webpack 加 ...

  9. JSBridge 知识点

    比较好的介绍文章: Android中JSBridge的原理与实现

  10. 利用pipeline批量插入数据到redis

    在推荐系统中,推荐候选集格式一般是,itemid itemid_list.要把itemid作为key,推荐列表作为value批量插入到redis. 比如文件cf.data为: cf_763500210 ...