nginx,php,tp框架版本:

nginx版本:
[root@z_centos nginx]# /usr/local/nginx/sbin/nginx -h
nginx version: nginx/1.13.9 tp5版本:
thinkphp 5.0.18 PHP版本:
[root@z_centos nginx]# php -v
PHP 7.2.3 (cli) (built: Mar 8 2018 14:43:32) ( ZTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.3, Copyright (c) 1999-2018, by Zend Technologies

usr/locol/nginx/conf/vhost/www.xxxx.com.conf 配置文件
主配置文件中使用 include ./vhost/*.conf; 引入即可

https 443端口配置项:

server {
listen 443 ssl;
server_name www.xxxx.com;
set $root /usr/local/nginx/webroot/tp5/public;
ssl_certificate /etc/letsencrypt/live/www.xxxx.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.xxxx.com/privkey.pem;
ssl_session_timeout 5m;
ssl_prefer_server_ciphers on;
access_log logs/www.myzb.pw.access.log main;
    
     if ($http_user_agent ~* "qihoobot|Baiduspider|YoudaoBot|Sosospider|Sogou spider|Sogou web spider|MSNBot|ia_archiver|Tomato Bot")
  {
   return 403;
  } location ~ ..(gif|jpg|jpeg|bmp|png|ico|txt|js|css)$
{
root $root;
}
location / {
root $root;
index index.php index.html index.htm;
if ( -f $request_filename) {
break;
} if ( !-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
}
} error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ .+\.php($|/) {
set $script $uri;
set $path_info "";
if ($uri ~ "^(.+\.php)(/.+)") {
set $script $1;
set $path_info $2;
} fastcgi_pass unix:/var/run/www/php-cgi.sock;
fastcgi_split_path_info ^((?U).+.php)(/?.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $root$fastcgi_script_name;
include fastcgi_params; } location ~ /\.(ht|svn|git) {
deny all;
}
}
http 80端口配置项:
server {
listen 80;
server_name tp510.manzb.top;
set $root /usr/local/nginx/www/tp510/public;
access_log logs/tp510.manzb.top.access.log main;
location ~ ..(gif|jpg|jpeg|bmp|png|ico|txt|js|css)$
{
root $root;
}
location / {
root $root;
index index.php index.html index.htm;
if ( -f $request_filename) {
break;
} if ( !-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
}
} error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ .+\.php($|/) {
set $script $uri;
set $path_info "";
if ($uri ~ "^(.+\.php)(/.+)") {
set $script $1;
set $path_info $2;
} fastcgi_pass unix:/var/run/www/php-cgi.sock;
fastcgi_split_path_info ^((?U).+.php)(/?.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $root$fastcgi_script_name;
include fastcgi_params; } location ~ /\.(ht|svn|git) {
deny all;
}
}

其中:fastcgi_pass之所以使用unix:/var/run/www/php-cgi.sock;配置参数,是因为:http://www.cnblogs.com/manzb/p/8875406.html

重启nginx时若出现了如下错误:

nginx: [emerg] unknown log format "proxy_log" in /usr/local/macports/etc/nginx/nginx.conf:147

解决办法:

打开nginx.conf,"main"错误是因为丢失了log_format选项,之前把他屏蔽掉了,修改之后问题解决。

http {
    include       mime.types;
    default_type  application/octet-stream;     log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

nginx配置thinkphp5的更多相关文章

  1. centos6.8 环境一键安装包 nginx配置thinkphp5

    ---恢复内容开始--- lnmp1.4 一键安装包 nginx配置thinkphp5     环境:Nginx1.12.1  PHP5.6  Coentos6.8 修改网站配置文件      ser ...

  2. nginx配置ThinkPHP5二级目录访问

    可以通过 http://www.mracale.com/项目名/模块名/方法名 进行访问 第一步 首先,你要确保在不配置二级目录的情况下,可以通过浏览器访问到.例如:http://www.mracal ...

  3. lnmp1.4 nginx配置thinkphp5

    vhost/xxx.conf配置图,重点是红色框框 研究了两三天 ,至此thinkphp5 路由,隐藏index.php全部解决 感谢网友的分享:http://blog.csdn.net/gaoxiu ...

  4. nginx配置反向代理或跳转出现400问题处理记录

    午休完上班后,同事说测试站点访问接口出现400 Bad Request  Request Header Or Cookie Too Large提示,心想还好是测试服务器出现问题,影响不大,不过也赶紧上 ...

  5. Windos环境用Nginx配置反向代理和负载均衡

    Windos环境用Nginx配置反向代理和负载均衡 引言:在前后端分离架构下,难免会遇到跨域问题.目前的解决方案大致有JSONP,反向代理,CORS这三种方式.JSONP兼容性良好,最大的缺点是只支持 ...

  6. Windows下Nginx配置SSL实现Https访问(包含证书生成)

    Vincent.李   Windows下Nginx配置SSL实现Https访问(包含证书生成) Windows下Nginx配置SSL实现Https访问(包含证书生成) 首先要说明为什么要实现https ...

  7. Nginx 配置简述

    不论是本地开发,还是远程到 Server 开发,还是给提供 demo 给人看效果,我们时常需要对 Nginx 做配置,Nginx 的配置项相当多,如果考虑性能配置起来会比较麻烦.不过,我们往往只是需要 ...

  8. Nginx配置详解

    序言 Nginx是lgor Sysoev为俄罗斯访问量第二的rambler.ru站点设计开发的.从2004年发布至今,凭借开源的力量,已经接近成熟与完善. Nginx功能丰富,可作为HTTP服务器,也 ...

  9. Nginx配置Https

    1.申请证书: https://console.qcloud.com/ssl?utm_source=yingyongbao&utm_medium=ssl&utm_campaign=qc ...

随机推荐

  1. mybatis mapper使用记录

    insert://插入一条数据//支持Oracle序列,UUID,类似Mysql的INDENTITY自动增长(自动回写)//优先使用传入的参数值,参数值空时,才会使用序列.UUID,自动增长int i ...

  2. LeetCode 628. Maximum Product of Three Numbers三个数的最大乘积 (C++)

    题目: Given an integer array, find three numbers whose product is maximum and output the maximum produ ...

  3. BugPhobia准备篇章:团队Beta阶段准备工作分析

    0x00:序言 To the searching tags, you may well fall in love withhttp://xueba.nlsde.buaa.edu.cn/ 再见,无忧时光 ...

  4. Alpha冲刺——day10

    Alpha冲刺--day10 作业链接 Alpha冲刺随笔集 github地址 团队成员 031602636 许舒玲(队长) 031602237 吴杰婷 031602220 雷博浩 031602634 ...

  5. [转帖] Linux 创建一个简单的私有CA、发证、吊销证书

    原创帖子地址:   https://blog.csdn.net/mr_rsq/article/details/71001810 Linux 创建一个简单的私有CA.发证.吊销证书 2017年04月30 ...

  6. JVM的自愈能力

    在IT行业,碰到问题的第一个反应通常是——“你重启过没”——而这样做可能会适得其反,本文要讲述的就是这样的一个场景. 接下来要介绍的这个应用,它不仅不需要重启,而且毫不夸张地说,它能够自我治愈:刚开始 ...

  7. terminal record & gif

    terminal record & gif ascii nema https://asciinema.org/ https://asciinema.org/docs/how-it-works ...

  8. Spring之AOP实现原理

  9. EntityFramework异常The specified cast from a materialized 'System.Double' type to the 'System.Single' type is not valid.

    实体类: public class ReportEntity { public string FactorName { get; set; } public double MaxVal { get; ...

  10. C# 爬虫小程序

    设计思路 主要基于Http Get请求网页数据,进行分析.涉及递归调用,多线程提高效率,守护线程等. 相关技术 抽象类 多线程 队列 Http Get请求 字符串解析 项目结构 AbsChain 职责 ...