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

前端之家收集整理的这篇文章主要介绍了亲测:LNMP环境下,解决项目缓冲慢、502以及配置https的问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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

解决办法:

 增加Nginx的upstream,其中upstream中为php-cgi的地址;Nginx作为,分支法解决并发量;增加php-cgi的进程数,(这里会受到机器资源的限制,因此,也并不能无限增加

解决了相关问题

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

listen PHP; root error_page 404 /404 location / PHP index.html index.htm; (!- rewrite ^(.*)$ /index.PHP?s=$ Nginx反向代理 此处是解决缓冲慢的重点部分 #location ~PHP$ { # fastcgi_pass .: location ~ \.PHP(.*404 try_files $uri =404 # fastcgi_pass .: fastcgi_pass .: PHP; fastcgi_split_path_info ^((?U).+\.PHP)(/?.+ }

# HTTPS server

listen root /usr/share/Nginx/html/ ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:! ssl_protocols TLSv1 TLSv1. TLSv1. location / root /usr/share/Nginx/html/项目名称 PHP; (!- rewrite ^(.*)$ /index.PHP?s=$

          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/项目名称;           
          fastcgi_pass .:10;           fastcgi_index index.PHP;           fastcgi_param HTTPS on;           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;           include fastcgi_params; # line           include fastcgi.conf;         }      }   强制转成的配置 及访问自动跳转对应地址上  server {     listen ;     server_name wx.ssgsrz.com;     rewrite ^/(.*) https:  }

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

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

猜你在找的Nginx相关文章