开始接触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;
#}
}
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安装,可以查看文章
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 ...
随机推荐
GAT2.0使用文档(单接口开发)
3 开始写用例 3.1接口用例开发 1) 准备工作 l 第一步从github(https://github.com/GeneralAutomationTesting/GAT2.0 ...
SDR 研究
最近终于买了一个RTL2832u 电视棒,可以软件无线电了 使用我的小米3开发板 (安卓6.0),直接在应用商店里搜索 "sdr",到豌豆荚中,就有“RTL驱动程序” 点击下载安装 ...
ViewConfiguration.getScaledTouchSlop () 用法
getScaledTouchSlop是一个距离,表示滑动的时候,手的移动要大于这个距离才开始移动控件.如果小于这个距离就不触发移动控件,如viewpager就是用这个距离来判断用户是否翻页 ViewC ...
用printf做彩色日志记录
写了一个简单的程序,但是考虑到有一些信息是需要打印在控制台上的,就像在windows上启动apache tomcat时控制台显示的信息一样.琢磨一会儿之后,对printf进行了封装,支持控制台打印日志 ...
Touch组件实现原理
Touch组件的实现主要解决了在pc端和移动端拖拽元素的功能. PC端: 依靠事件: mousedown,mousemove,mouseup的鼠标事件.过程: 1. mousedown事件中记录当前元 ...
Linux发行版 CentOS6.5下的分区操作
本文地址http://comexchan.cnblogs.com/ ,尊重知识产权,转载请注明出处,谢谢! 查询磁盘信息并作分区规划 执行下述命令查询磁盘信息: fdisk -l 可知.数据盘大小50 ...
[Err] ORA-00923: FROM keyword not found where expected 与rownum
关于oracle的nownum 如果我想查询表的全部信息,并且前面加上行号,sql如下 select ROWNUM,* from tableA 会报下面的错误 [Err] ORA-00923: FR ...
django 部署,gunicorn、virtualenv、nginx
声明: 1.本篇文章是我边写命令边写的,请尊重我的劳动成果,转载请加上链接. 2.我既然公开写出来,是希望大家遇到问题的时候有个参考,所以,大家可以免费转载,使用该文章 3.但是,如果你要用这篇文章来 ...