在做的项目在nginx下访问缓冲时间过长,明显比apache下访问蛮11倍有余,

解决办法:

  1增加nginx的upstream,其中upstream中为php-cgi的地址;
  2利用nginx作为反向代理,分支法解决并发量;
  3增加php-cgi的进程数,(这里会受到机器资源的限制,因此,也并不能无限增加)

我这里使用了反向代理这各办法解决了相关问题

下面把具体解决办法放在下面,顺便把nginx下配置项目的配置贴出来,供大家使用

 server {
listen ;
server_name 你的域名;
index index.html index.htm index.php;
root /yjdata/www/www/tp5_houtai/public;
error_page /.html; location / {
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$ last;
break;
}
#nginx反向代理 此处是解决缓冲慢的重点部分
proxy_read_timeout 300;
16 proxy_connect_timeout 300;
17 proxy_set_header X-Real-IP $remote_addr;
18 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
19 proxy_set_header Host $http_host;
20 proxy_redirect off;
#autoindex on;
}
#location ~ \.php$ {
# fastcgi_pass 127.0.0.1:;
# include fastcgi.conf;
#}
location ~ \.php(.*)$ {
#配置404
try_files $uri =;
#此处是9000或者10000根据自己服务器实际情况改 我这里是10000
# fastcgi_pass 127.0.0.1:;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
include fastcgi.conf;
}
}

配置https 1 # HTTPS server

     #
server {
listen ssl;
server_name 你的域名;
root /usr/share/nginx/html/wxssgsrz; index index.html index.htm;
#相关证书
10 ssl_certificate cert/214757705190741.pem;
11 #相关证书
12 ssl_certificate_key cert/214757705190741.key; ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1. TLSv1.;
ssl_prefer_server_ciphers on;
location / {
root /usr/share/nginx/html/项目名称;
index index.html index.htm index.php;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$ last;
break;
}

          proxy_read_timeout 300;
          proxy_connect_timeout 300;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $http_host;
          proxy_redirect off;

         }

         location ~ .*\.(php|php5)?$ {
root /usr/share/nginx/html/项目名称;
          #此处是9000或者10000根据自己服务器实际情况改 我这里是10000
          fastcgi_pass 127.0.0.1:10; 
         fastcgi_index index.php;
        fastcgi_param HTTPS on;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
34         #new line
         include fastcgi.conf;
      }
     } #此处是把http强制转成https的配置 及访问http会自动跳转到https对应地址上
server {
   listen ;
  server_name wx.ssgsrz.com;
   rewrite ^/(.*) https://$server_name$request_uri? permanent;
}

好了  多余的不说了 ,大家复制拿去用就是了

谢谢大家浏览到这里~~~

亲测:LNMP环境下,解决项目缓冲慢、502以及配置https的问题的更多相关文章

  1. Thinkphp在Lnmp环境下部署项目先后报错问题解决:_STORAGE_WRITE_ERROR_:./Application/Runtime/Cache/Home/...Access denied.

    首先报错:_STORAGE_WRITE_ERROR_:./Application/Runtime/Cache/Home/769e70f2e46f34ceb60619bbda5e4691.php 解决此 ...

  2. 记一次lnmp环境下无法执行php文件

    lnmp环境搭建好后却无法正常执行php文件,坑爹啊!~ [错误状况] 页面直接打印出php代码内容: php文件无法执行?: 查看nginx配置文件: server { listen 80; ser ...

  3. 在centos6.7中lnmp环境下安装swoole插件和pthreads插件

    1.首先在安装lnmp集成包之前,解压lnmp1.3-full.tar.gz,进入到lnmp1.3-full/include/目录下; 2.输入 vi php.sh;编辑php.sh文档.博主安的是p ...

  4. php-cgi和php-fpm,Windows环境下解决Nginx+php并发访问阻塞问题。

    php-cgi 是运行php,php-fpm是守护php-cgi进程 nginx配置目录运行php        location  ~ \.php$        {                 ...

  5. thinkphp 5.0 lnmp环境下 无法访问,报错500(public目录)

    两种方法: 1.修改fastcgi的配置文件 /usr/local/nginx/conf/fastcgi.conf fastcgi_param PHP_ADMIN_VALUE "open_b ...

  6. linux搭建的LNMP环境下的mysql授权远程连接

    用phpstudy搭建的lnmp环境下mysql授权远程连接 简单高效 这是因为mysql 里的优先级不是所有人(提前检查防火墙是关闭状态)1.使用phpstudy安装的mysql没有放置到可以直接调 ...

  7. 本人亲测-SSM环境搭建(使用eclipse作为示例,过程挺全的,可作为参考)

    本人亲测-SSM环境搭建(使用eclipse作为示例,过程挺全的,可作为参考) 本人亲测-SSM环境搭建(使用eclipse作为示例,过程挺全的,可作为参考) 本人亲测-SSM环境搭建(使用eclip ...

  8. linux lnmp环境下 安装apache教程

    linux lnmp环境下 安装apache教程 源码安装 apr ,apr-util 安装apache要用<pre>wget http://mirrors.cnnic.cn/apache ...

  9. (转 留存)Windows环境下的NodeJS+NPM+GIT+Bower安装配置步骤

    Windows环境下的NodeJS+NPM+GIT+Bower安装配置步骤 标签: NodeJSnpmbower 2015-07-17 16:38 3016人阅读 评论(0) 收藏 举报  分类: G ...

随机推荐

  1. 【Node100In1】01.去异步,解决掉Node.js万恶的回调陷阱

    Node.js是基于事件驱动编程.异步函数随处可见,其中不乏一些常用库的方法.本例就以js中最常见的setTimeout的为例,试图改善一下回调的书写. 先来看一段伪代码: 我们实现一个需求,每隔一段 ...

  2. JavaScript使用浏览器内置XMLHttpRequest对象执行Ajax请求

    所有现代浏览器均支持 XMLHttpRequest 对象(IE5 和 IE6 使用 ActiveXObject).XMLHttpRequest 用于在后台与服务器交换数据.这意味着可以在不重新加载整个 ...

  3. 从PMP培训归来,跟大家聊聊做项目的套路

    管理也是一些套路的传承,很多人说不去学专门的管理,照样把工作做得很好.是的,不是散打乱打就不能赢,只是会吃点亏而已.如果你有了套路在心中,那么必定会让自己车到山前开路,让事情更好办. 所以,我去学了几 ...

  4. java 实现一个beautiful的弹层和具体功能

    先看一下弹层的效果: 点击确定跳转百度页面,点击取消弹层消失. 我这个弹层是在layui找的, 1. 需要layui.css文件和layui.js文件 (想我这样笨的人,没有同学的告知,我都不知道去哪 ...

  5. Spring 通知和顾问进行增强

    使用顾问增加前置增强和后置增强 <bean id="1" class="目标对象"></bean> <bean id=" ...

  6. [Oracle]使用InstantClient访问Oracle数据库

    环境 操作系统: Win8.1 Enterprise Oracle开发工具: PL/SQL Developer 7.0.1.1066 (MBCS) 步骤 下载InstantClient Oracle官 ...

  7. ImportError: No module named '_tkinter', please install the python3-tk package

    ImportError: No module named '_tkinter', please install the python3-tk package 先更新包,命令:sudo apt-get ...

  8. 好用的shell可以事半功倍

    程序员离不开shell,一个好用的shell可以事半功倍,推荐zsh以及一些插件 # install zsh $ brew install zsh # install a framework, we ...

  9. Android内存管理篇 - adj的概念与进程adj级别控制

    本文主要介绍Android的lowmemorykiller的oom_adj的相关概念,以及根据一些案例来阐述了解oom_adj对于做Android应用开发的重要意义. 一.lowmeorykiller ...

  10. leetcode — jump-game

    /** * Source : https://oj.leetcode.com/problems/jump-game/ * * Created by lverpeng on 2017/7/17. * * ...