Nginx连接超时怎么办,进程管理优化助您化解

  

下文给大家带来Nginx连接超时怎么办,进程管理优化助您化解,希望能够给大家在实际运用中带来一定的帮助,负载均衡涉及的东西比较多,理论也不多,网上有很多书籍,今天我们就用在行业内累计的经验来做一个解答。

Nginx之连接超时

在企业网站中,为了避免同一个客户长时间占用连接,造成资源浪费
可设置相应的连接超时参数,实现控制连接访问时间

 Nginx连接超时怎么办,进程管理优化助您化解
配置Nginx
 <代码> [root@localhost ~] # yum安装pcre-devel zlib-devel gcc gcc-c + + - y # #安装环境包
  
  (root@localhost ~) # useradd - m - s/sbin/nologin nginx, # #创建程序性用户
  
  (root@localhost ~) # mkdir/陈,# #创建挂载点
  root@localhost ~ #山。cifs//192.168.100.23 LNMP/陈,# #挂载
  密码root@//192.168.100.23/LNMP:,
  
  (陈root@localhost) #焦油zxvf nginx-1.12.2.tar。广州- c/opt/, # #解压
  
  (陈root@localhost) # cd/opt/root@localhost选择# ls
  nginx-1.12.2,猕
  root@localhost选择# cd nginx-1.12.2/[root@localhost nginx-1.12.2] # ls
  汽车,,CHANGES.ru,配置,html,,男人,,src
  变化,相依,,,contrib大敌;许可,README
  
  ./configure \, # #安装nginx组件
  ——prefix=/usr/地方/nginx \
  ——用户=nginx \
  ——组=nginx \
  ——with-http_stub_status_module
  
  [root@localhost nginx-1.12.2] #做,,使安装# #编译
  
  [root@localhost nginx-1.12.2] # ln - s/usr/local/nginx/sbin/nginx/usr/local/sbin/# #做软链接让系统能识别nginx的所有人命令
  [root@localhost nginx-1.12.2] # nginx - t, # #检查语法错误/usr/local/nginx/conf/nginx. nginx:配置文件配置语法好/usr/local/nginx/conf/nginx. nginx:配置文件配置测试是成功的 
写nginx脚本放在系统启动脚本中方便服务管理器管理
 <代码> [root@localhost nginx-1.12.2] # cd/etc/init.d/# #到系统启动脚本
  
  [root@localhost init。d] # vim nginx,# #写一个nginx脚本
  
  # !/bin/bash
  # chkconfig: 20 - 99, #注释信息
  描述:Nginx服务控制脚本
  学监=?usr/地方/nginx/sbin/nginx",#这个变量,指向我的命令文件
  PIDF=?usr/地方/nginx/日志/nginx.pid",#这个变量,指向nginx的进程号
  例“1美元,在
  ,,开始)
  ,,,学监美元大敌;,,,,,,,,,,,,,,,,,,,,,,
  ,,,,;;
  ,,停止)
  ,,,,杀死- s退出美元(猫PIDF美元)
  ,,,,;;
  ,,重启),,,,,,,,,,,,,,,,,,,,,,,,
  ,,,0美元停止
  ,,,0美元开始
  ,,,,;;
  ,,重新加载),,,,,,,,,,,,,,,,,,,,,,,,
  ,,,美元,杀死- s玫瑰(猫PIDF美元)
  ,,,,;;
  ,,*),,,,,,,,,,,,,,,,,,,,,,,,,,,,
  ,,,,,,,0美元,呼应“用法:{开始|停止|重启|重载}“;
  ,,,,,,,1,退出
  esac
  退出0
  
  [root@localhost init。d] # chmod + x nginx, # #给nginx提升权限
  [root@localhost init。d] # chkconfig——添加nginx, # #添加nginx
  [root@localhost init。d] #服务nginx的开始
  [root@localhost init。d] # netstat -ntap | grep nginx
  tcp,,,,0,0 0.0.0.0:80大敌;,,,,,,0.0.0.0:*,,,,,,,听,,17544/nginx:大师
  
  [root@localhost init。d] # systemctl firewalld.service停止
  [root@localhost init。d] # setenforce 0  
配置连接超时
修改nginx配置文件
 <代码> root@localhost ~ # cd/usr/local/nginx/conf/(root@localhost conf) # vim nginx。参看 
在http协议级别区域中添加
 <代码> 31,,keepalive_timeout, 65 180;# # 65是云服务器超时时间,180是客户端超时时间
  32,,client_header_timeout 80;80年,# #是网页中的头部超时时间
  33,,client_body_timeout 80;80年,# #是网页中身体的超时时间
  (root@localhost conf) # nginx停止服务
  (root@localhost conf) #服务nginx开始 

nginx进程管理优化

查看进程

 <代码> [root@localhost conf] # ps辅助| grep nginx
  根,,0.0,0.0,51524,20544,600年?,,,党卫军大敌;20:05,0:00 nginx:主人/usr/local/nginx/sbin/nginx过程
  nginx,,51525,0.0,0.0,23072,1388 ?,,,年代的大敌;20:05大敌;0:00 nginx:工作进程
  根,,112728年,51531年的0.0,0.0,972分/3,S +大敌;20:06,null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null

Nginx连接超时怎么办,进程管理优化助您化解