nginx 1.14.0 配置部署 thinkphp 5.1
开始接触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的更多相关文章
- centos 7.2 下 nginx 1.14.1 安装部署
Nginx1.14.1安装部署 1.环境: 所有源码在跳板机kx的/web/soft下 2.安装依赖: [root@bogon src]# yum install -y libxml2 openssl ...
- CentOS 7.4安装Nginx 1.14.0
一.安装所需环境 1.gcc 安装 yum install gcc-c++
- nginx HTTP/2.0 配置
1.前言 最近无意中看到http2.0消息,发现自己的博客虽然配了https,但并没有配置http2.0,所以搞了个玩玩,本以为配个参数就搞定了,结果还是折腾了一个小时. 2.过程 nginx并没有默 ...
- Centos 7 编译nginx 1.14.0
步骤一:下载nginx安装包 wget https://nginx.org/download/nginx-1.14.0.tar.gz 步骤二:安装nginx依赖包 yum install -y gcc ...
- kubenetes_V1.14.0 安装部署
k8s的安装有多种方式,如yum安装,kubeadm安装,kubemini安装,二进制安装(生产环境多采用此方式精确控制安装)等.本文是入门系列验证,之前进行过yum安装,可以查看文章<k8s入 ...
- 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 查看硬 ...
- Nginx HA 及https配置部署
Nginx HA 整体方案架构为: (内网192.168.199.5) +-----------VIP----------+ | | | | Master Backup 192.168.199.90 ...
- Nginx安装负载均衡配置 fair check扩展
前言 本文主要是针对Nginx安装.负载均衡配置,以及fair智能选举.check后端节点检查扩展功能如何扩展,进行讲解说明. fair模块: upstream-fair,“公平的”Nginx 负载均 ...
- Ubuntu 16.04 安装最新稳定版Nginx 1.6.0
Ubuntu 16.04 默认安装的是nginx 1.14.0 #默认安装方式:apt-get install nginx 1.查看是否安装nginx,如果已经安装,请先卸载 #查看安装版本 d ...
随机推荐
- Go Example--switch
package main import ( "fmt" "time" ) func main() { i := 2 fmt.Print("write ...
- 【TCP/IP】二、协议的概念
一.概念 1.tcp/ip是通信协议的统称. 2.协议就是计算机与计算机之间通过网络实现通信时,事先达成的一种约定.这种约定,使那些不同厂商的设备,不同的CPU以及不同的操作系统组成的计算机之间,只要 ...
- 使用mongoose连接mongodb(转载文章)
mongodb数据库 MongoDB是一个高效的基于分布式文件存储的数据库,将数据存储为一个文档,数据结构由键值(key=>value)对组成.MongoDB 文档类似于 JSON 对象.字段值 ...
- 利用JavaScript jQuery实现图片无限循环轮播(不借助于轮播插件)-----转载
前言 作为一个前端工程师,无论公司是什么行业,无论你做什么端,基本都会遇到一个避不开的动画效果:循环轮播.做轮播并不难,市场上的轮播插件有很多,其中比较著名的是swiper,使用也非常简单.但轮播插件 ...
- android设备兼容性
原文地址:http://developer.android.com/guide/practices/compatibility.html android被设计成能够在多种不同的设备上执行的系统,为了达 ...
- 常用gui软件使用技巧
xmind powerdesinger notepad++ firefox office ========================================= win10企业版安装 xm ...
- e.target和e.srcElement
IE下,event对象有srcElement属性,但是没有target属性; Firefox下,event对象有target属性,但是没有srcElement属性.但他们的作用是相当的,即: fire ...
- ML(4)——逻辑回归
Logistic Regression虽然名字里带“回归”,但是它实际上是一种分类方法,“逻辑”是Logistic的音译,和真正的逻辑没有任何关系. 模型 线性模型 由于逻辑回归是一种分类方法,所以我 ...
- springfox+swagger2生成API文档
1.建立一个spring mvc工程: 2.添加POM依赖: <properties> <springfoxversion>2.6.1</springfoxversion ...
- npx:npm包执行器
npx 作用: 单次执行命令而不需要安装到本机 执行依赖包里的二进制文件 使用不同版本的 node 利用 npx 可以下载模块这个特点,可以指定某个版本的 Node 运行脚本.它的窍门就是使用 npm ...