Nginx优化

Auther:Rich七哥

案例环境:

系统类型 IP地址 主机名 所需软件
Centos 6.5 192.168.1.78 harry78 nginx-1.6.2.tar.gz

一、Nginx隐藏版本号;

方式一:修改配置文件

Ø 安装Nginx

[root@www ~]# yum -y install pcre-devel zlib-devel popt-devel openssl-devel openssl
​
[root@www ~]# useradd -M -s /sbin/nologin nginx
​
[root@www ~]# tar zxvf nginx-1.6.2.tar.gz -C /usr/src/
​
[root@www ~]# cd /usr/src/nginx-1.6.2/
​
[root@www nginx-1.6.2]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-file-aio --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-http_ssl_module --with-pcre && make && make install
​
[root@www nginx-1.6.2]# cd
​
[root@www ~]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
​
[root@www ~]# nginx
​
[root@www ~]# netstat -utlpn |grep 80
​
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      5618/nginx          

Ø 配置版本号隐藏;

[root@www ~]# curl -I http://harry78                       ##选项为-i
​
HTTP/1.1 200 OK
​
Server: nginx/1.6.2
​
Date: Wed, 11 Jul 2018 16:43:05 GMT
​
Content-Type: text/html
​
Content-Length: 612
​
Last-Modified: Wed, 11 Jul 2018 16:40:55 GMT
​
Connection: keep-alive
​
ETag: "5b463317-264"
​
Accept-Ranges: bytes
​
[root@www ~]# vi /usr/local/nginx/conf/nginx.conf                 ##在http{}内添加即可
​
    20     server_tokens off;
​
:wq
​
[root@www ~]# nginx -t                                 ##检查nginx配置文件语法
​
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
​
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
​
[root@www ~]# killall -9 nginx        
​
[root@www ~]# nginx  
​
[root@www ~]# curl -I http://harry78
​
HTTP/1.1 200 OK
​
Server: nginx                                                        ##版本已经隐藏
​
Date: Fri, 08 Dec 2017 22:56:00 GMT
​
Content-Type: text/html
​
Content-Length: 612
​
Last-Modified: Fri, 08 Dec 2017 22:47:50 GMT
​
Connection: keep-alive
​
ETag: "5a2b1696-264"
​
Accept-Ranges: bytes

方式二:修改源码包;

[root@localhost ~]# yum -y install pcre-devel zlib-devel popt-devel openssl-*
​
[root@localhost ~]# useradd -M -s /sbin/nologin nginx
​
[root@localhost ~]# tar zxf nginx-1.6.2.tar.gz -C /usr/src/
​
[root@localhost ~]# cd /usr/src/nginx-1.6.2/
​
[root@localhost nginx-1.6.2]# vim src/core/nginx.h                     ##修改源代码实现隐藏版本
​
13 #define NGINX_VERSION     "6.6.6"
​
14 #define NGINX_VER         "harry.cn/" NGINX_VERSION
​
15
​
16 #define NGINX_VAR         "harry.cn"
​
:wq
​
[root@localhost nginx-1.6.2]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-file-aio --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-http_ssl_module --with-pcre && make && make install
​
[root@localhost nginx-1.6.2]# cd
​
[root@localhost ~]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
​
[root@localhost ~]# nginx
​
[root@localhost ~]# curl -I http://harry78
​
HTTP/1.1 200 OK
​
Server: harry.cn/6.6.6
​
Date: Fri, 08 Dec 2017 23:06:20 GMT
​
Content-Type: text/html
​
Content-Length: 612
​
Last-Modified: Fri, 08 Dec 2017 23:05:45 GMT
​
Connection: keep-alive
​
ETag: "5a2b1ac9-264"
​
Accept-Ranges: bytes

二、网页缓存、连接超时、网页压缩传输;

1.**网页缓存:**

作用:页面缓存一般针对静态网页进行设置,对动态网页不用设置缓存时间。方便客户端

在日后进行相同内容的请求时直接返回,以避免重复请求,加快了访问速度。

配置nginx缓存:

[root@www ~]# cat <<END >/usr/local/nginx/html/index.html
​
<html>
​
<head>
​
<title>harry78</title>
​
</head>
​
<body>
​
harry78
​
​
​
</body>
​
</html>
​
END
​
[root@www ~]# ls /usr/local/nginx/html/
​
index.html linux.jpg
​
[root@www ~]# vi /usr/local/nginx/conf/nginx.conf
​
    55         location ~ .(gif|jpg|jpeg|png|bmp|ico)$   {
​
    56             expires 1d;
​
    57         }
​
    58         location ~ .*.(js|css)$   {    
​
    59             expires 1h;          
​
    60         }
​
:wq
[root@www ~]# nginx -t
​
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
​
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
​
[root@www ~]# killall -9 nginx
​

配置连接超时:

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

配置项:

keepalived_timeout 设置连接保持超时时间,一般可只设置该参数,默认为 65 秒,可根据网站的情况设置,或者关闭,可在 http 段、 server 段、或者 location 段设置。
client_header_timeout 指定等待客户端发送请求头的超时时间。
client_body_timeout 设置请求体读取超时时间。
注意: 若出现超时,会返回 408 报错  
[root@www ~]# vi /usr/local/nginx/conf/nginx.conf
​
    32     keepalive_timeout  65;
​
    33     client_header_timeout 60;
​
    34     client_body_timeout 60;
​
:wq
​
[root@www ~]# killall -9 nginx
​
[root@www ~]# nginx -t
​
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
​
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
​
[root@www ~]# nginx
​

3.网页压缩传输:

作用:将服务端传输的网页文件压缩传输,使其更加快速、减少带宽的占用;

配置:

[root@www ~]# vi /usr/local/nginx/conf/nginx.conf
​
    37     gzip on;                      ##开启 gzip 压缩输出
​
    38     gzip_min_length 1k;                            ##用于设置允许压缩的页面最小字节数
​
    39     gzip_buffers 4 16k;                            ##表示申请4 个单位为 16k 的内存作为压缩结果流缓存,默认值是申请与原始数据大小相同的内存空间来储存 gzip 压缩结果
​
    40     gzip_http_version 1.1;                       # #设置识别 http 协议版本,默认是 1.1
​
    41     gzip_comp_level 2;                            ##gzip 压缩比, 1-9 等级
​
    42   gzip_types text/plain text/javascript application/x-javascript text/css text/xml application/xml application/xml+rss;                    ##压缩类型,是就对哪些网页文档启用压缩功能
​
[root@www ~]# nginx -t
​
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
​
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
​
[root@www ~]# killall nginx
​
[root@www ~]# nginx

三、访问控制、定义错误页面、自动索引、目录别名;

1.**访问控制:**

作用:限制访问网站资源;

配置项:

auth_basic "Nginx Status"; 认证提示文字
auth_basic_user_file /usr/local/nginx/conf/user.conf; 认证用户文件,可以使用apache提供的htpasswd命令来生成文件
allow 192.168.100.1; 允许客户端ip地址
deny 192.168.100.0/24; 拒绝的网段

配置:

[root@www ~]# yum -y install httpd-tools
​
[root@www ~]# htpasswd -c /usr/local/nginx/conf/user.conf zs
​
[root@www ~]# cat /usr/local/nginx/conf/user.conf
​
zs:VJVdQdVHEIvZo
​
[root@www ~]# vi /usr/local/nginx/conf/nginx.conf
​
    70         location /status       {
​
    71                 stub_status on;
​
    72                 access_log off;
​
    73                 auth_basic "Nginx Status";
​
    74                 auth_basic_user_file /usr/local/nginx/conf/user.conf;
​
    75                 allow 192.168.100.1;
​
    76                 deny 192.168.100.0/24;
​
    77         }
​
[root@ www ~]# killall -9 nginx
​
[root@ www ~]# nginx

客户端访问验证:

2.**定义错误页面:**

作用:根据客户端的访问网站的返回状态码,为其指定到特定的错误页面;

配置:

[root@ www ~]# vi /usr/local/nginx/conf/nginx.conf

78 error_page 403 404 /404.html;

79 location = /404.html {

80 root html;

81 }

[root@ www ~]# echo "deny" >>/usr/local/nginx/html/404.html

[root@ www ~]# killall -9 nginx

[root@www ~]# nginx

客户端访问验证:

3.**自动索引:**

作用:将网站转化为类似ftp的站点,作为共享文件的工具;

配置:

[root@www ~]# mkdir  -p  /usr/local/nginx/html/download/haha/
​
[root@www ~]# touch /usr/local/nginx/html/download/haha/{1..10}.txt
​
[root@www ~]# vi /usr/local/nginx/conf/nginx.conf
​
    82         location /download {
​
    83                 autoindex on;
​
    84         }
​
[root@www ~]# killall -9 nginx
​
[root@www ~]# nginx

客户端访问测试:

4.**目录别名:**

作用:将域名后缀的路径设置一个别名,通过多种方式访问;

配置:

[root@www ~]# vi /usr/local/nginx/conf/nginx.conf
​
    85         location /dw {
​
    86                 alias /usr/local/nginx/html/haha/;
​
    87         }
​
[root@www ~]# mkdir /usr/local/nginx/html/haha
​
[root@www ~]# echo "haha" >/usr/local/nginx/html/haha/index.html
​
[root@www ~]# killall -9 nginx
​
[root@www ~]# nginx

客户端访问测试:

四、日志分割;

方式:脚本方式

技术要点:

a.剪切日志后,使用kill -USR1发送信号重新生成日志文件,同时还不影响网站请求处理进程。

b.错误时通过echo和tee -a命令将错误显示的同时写入到日志文件/var/log/messages。

[root@www ~]# vi /root/cut_nginx_log.sh
​
#!/bin/bash
​
# by harry78 cut_nginx_log.sh
​
datetime=$(date -d "-1 day" "+%Y%m%d")
​
log_path="/usr/local/nginx/logs"
​
pid_path="/usr/local/nginx/logs/nginx.pid"
​
mkdir -p $log_path/backup
​
if [ -f $pid_path ]
​
then
​
mv log_path/access.log log_path/backup/access.log-$datetime
​
kill -USR1 (cat pid_path)
​
##USR1通常被用来告知应用程序重载配置文件;
​
find $log_path/backup -mtime +30 | xargs rm -f
​
else
​
echo "Error,Nginx is not working!" >> /var/log/messages
​
fi
​
:wq
​
[root@www ~]# chmod +x /root/cut_nginx_log.sh
​
[root@www ~]# echo "0 0 * * * /root/cut_nginx_log.sh" >>/var/spool/cron/root
​
[root@www ~]# crontab -l
​
0 0 * * * /root/cut_nginx_log.sh
​
[root@www ~]# sh -x /root/cut_nginx_log.sh
​
[root@www ~]# ls /usr/local/nginx/logs/
​
access.log backup error.log nginx.pid
​
[root@www ~]# ls /usr/local/nginx/logs/backup/
​
access.log-20171208
​

五、虚拟主机;

作用:在同一台服务器上部署多个网站,减免资源的占用;

实现方式:

1.不同IP,不同域名,相同端口;

2.相同IP,相同域名,不同端口;

3.相同IP,相同端口,不同域名;

案例环境:

系统类型 IP地址 主机名 所需软件
Centos 6.5 192.168.100.151 harry666 nginx-1.6.2.tar.gz

方式一:不同IP,不同域名,相同端口;

[root@harry ~]# ip a |grep 192.168.100
​
  inet 192.168.100.151/24 brd 192.168.100.255 scope global eth0
​
  inet 192.168.100.200/24 brd 192.168.100.255 scope global secondary eth0:0
​
[root@linharry# vi /usr/local/nginx/conf/nginx.conf
​
worker_processes 1;
​
      events {
​
          use epoll;
​
          worker_connections 4096;
​
              }
​
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" ';
​
      access_log logs/access.log main;
​
      sendfile on;
​
      keepalive_timeout 65;
​
server {
​
  listen 192.168.100.151:80;
​
  server_name harry78;
​
  charset utf-8;
​
  access_log logs/harry.access.log main;
​
  location / {
​
    root /var/www/harry/;
​
    index index.html index.php;
​
      }
​
    }
​
server {
​
  listen 192.168.100.200:80;
​
  server_name www.harry.cn;
​
  charset utf-8;
​
  access_log logs/harry.access.log main;
​
  location / {
​
    root /var/www/harry/;
​
    index index.html index.php;
​
      }
​
    }
​
}
​
[root@linuxrharrykdir -p /var/www/harry
​
[root@linuxren harryr -p /var/www/harry
​
[root@linuxren ~]#harryarry78" >/var/www/harry/index.html
​
[root@linuxren ~]# echarryharry.cn" >/var/www/harry/index.html
​
[root@linuxren ~]# killaharryinx
​
[root@linuxren ~]# nginx
harry

客户端访问测试:

方式二:相同**IP,不同域名,相同端口;**

[root@harry ~]# vi /usr/local/nginx/conf/nginx.conf
​
worker_processes 1;
​
      events {
​
          use epoll;
​
          worker_connections 4096;
​
              }
​
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" ';
​
      access_log logs/access.log main;
​
      sendfile on;
​
      keepalive_timeout 65;
​
server {
​
  listen 192.168.100.151:80;
​
  server_name harry78;
​
  charset utf-8;
​
  access_log logs/harry.access.log main;
​
  location / {
​
    root /var/www/harry/;
​
    index index.html index.php;
​
      }
​
    }
​
server {
​
  listen 192.168.100.151:80;
​
  server_name www.harry.cn;
​
  charset utf-8;
​
  access_log logs/harry.access.log main;
​
  location / {
​
    root /var/www/harry/;
​
    index index.html index.php;
​
      }
​
    }
​
}
​
[root@linharry# killall -9 nginx
​
[root@linuxrharryginx
​

客户端访问测试:

方式三:相同IP,不同端口,相同域名;

[root@harry ~]# vi /usr/local/nginx/conf/nginx.conf
​
worker_processes 1;
​
      events {
​
          use epoll;
​
          worker_connections 4096;
​
              }
​
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" ';
​
      access_log logs/access.log main;
​
      sendfile on;
​
      keepalive_timeout 65;
​
server {
​
  listen 192.168.100.151:80;
​
  server_name harry78;
​
  charset utf-8;
​
  access_log logs/harry.access.log main;
​
  location / {
​
    root /var/www/harry/;
​
    index index.html index.php;
​
      }
​
    }
​
server {
​
  listen 192.168.100.151:8080;
​
  server_name harry78;
​
  charset utf-8;
​
  access_log logs/harry.access.log main;
​
  location / {
​
    root /var/www/harry/;
​
    index index.html index.php;
​
      }
​
    }
​
}
​
[root@linharry# killall -9 nginx
​
[root@linuxrharryginx
​

客户端访问测试:

六、平滑升级;

原理:

1.Nginx 的主进程( master process)启动后完成配置加载和端口绑定等动作, fork 出指定数量的工作进程( worker process),这些子进程会持有监听端口的文件描述符( fd),并通过在该描述符上添加监听事件来接受连接( accept);

2.Nginx 主进程在启动完成后会进入等待状态,负责响应各类系统消息,如 SIGCHLD、 SIGHUP、SIGUSR2 等;

3.主进程支持的信号:

TERM, INT: 立刻退出; QUIT: 等待工作进程结束后再退出

KILL: 强制终止进程; HUP: 重新加载配置文件,使用新的配置启动工作进程,并逐步关闭旧进程。

USR1: 重新打开日志文件; USR2: 启动新的主进程,实现热升级

WINCH: 逐步关闭工作进程及工作进程支持的信号;

过程:

1.查看旧版 nginx 的编译参数;

2.编译新版本 Nginx 源码包,安装路径需与旧版一致,注意:不要执行 make install;

3.备份二进制文件,用新版本的替换;

4.确保配置文件无报错;

5.发送 USR2 信号:向主进程( master)发送 USR2 信号, Nginx 会启动一个新版本的 master 进程和对应工作进程,和旧版一起处理请求;

6.发送 WINCH 信号:向旧的 Nginx 主进程( master)发送 WINCH 信号,它会逐步关闭自己的工作进程(主进程不退出),这时所有请求都会由新版 Nginx 处理;

7.发送 QUIT 信号:升级完毕,可向旧的 Nginx 主进程( master)发送( QUIT、 TERM、或者 KILL)信号,使旧的主进程退出;

8.验证 nginx 版本号,并访问测试;

配置:

Ø  准备软件包并查看旧版安装选项;
​
[root@harry ~]# ls nginx-1.*
​
nginx-1.12.0.tar.gz nginx-1.6.2.tar.gz
​
[root@harry ~]# nginx -V
​
nginx version: nginx/1.6.2
​
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC)
​
TLS SNI support enabled
​
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-file-aio --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-http_ssl_module --with-pcre
​ ​
Ø 安装新版本Nginx;
​
[root@harry ~]# tar zxvf nginx-1.12.0.tar.gz -C /usr/src/
​
[root@harry ~]# cd /usr/src/nginx-1.12.0/
​
[root@harry nginx-1.12.0]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-file-aio --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-http_ssl_module --with-pcre && make                 ##不能加make install,如若添加,则覆盖了
​
[root@harry nginx-1.12.0]# mv /usr/local/nginx/sbin/nginx   /usr/local/nginx/sbin/nginx.old
​
[root@harry nginx-1.12.0]# cp objs/nginx /usr/local/nginx/sbin/
​
[root@harry nginx-1.12.0]# nginx -t
​
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
​
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
​
[root@harry nginx-1.12.0]# cd
​ ​
Ø 使用信号实现热升级;
​
[root@harry ~]# ps aux |grep nginx |grep -v grep
​
root       6059(老版本主进程)  0.0  0.2  45000  1032 ?       Ss   13:03   0:00 nginx: master process nginx
​
nginx      6060  0.0  0.3  45432  1624 ?       S    13:03   0:00 nginx: worker process
​
[root@harry ~]# kill -USR2 6059                                 ##发送 USR2 信号:向主进程( master)发送 USR2 信号, Nginx 会启动一个新版本的 master 进程和对应工作进程,和旧版一起处理请求。
​
[root@harry ~]# kill -WINCH $(cat /usr/local/nginx/logs/nginx.pid)                     ##关闭老版本的worker进程
​
[root@harry ~]# kill -QUIT $(cat /usr/local/nginx/logs/nginx.pid)                         ##关闭老版本的master进程
​
[root@harry ~]# /usr/local/nginx/sbin/nginx                                           ##重新加载新版本的命令
​
[root@harry ~]# ps aux |grep nginx |grep -v grep
​
root      3864  0.0  0.2  45192  1188 ?       Ss   03:24   0:00 nginx: master process /usr/local/nginx/sbin/nginx
​
nginx     3865  0.0  0.6  46904  3052 ?       S    03:24   0:00 nginx: worker process
​
[root@harry ~]# nginx -V
​
nginx version: nginx/1.12.0
​
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC)
​
built with OpenSSL 1.0.1e-fips 11 Feb 2013
​
TLS SNI support enabled
​
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-file-aio --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-http_ssl_module --with-pcre
​

七、加载第三方模块;

第三方模块下载地址:**https://www.nginx.com/resources/wiki/modules/**

模块:**echo-nginx-module-0.60.tar.gz**

[root@harry ~]# ls
​
echo-nginx-module-0.60.tar.gz nginx-1.6.2.tar.gz
​
[root@harry ~]# tar zxvf echo-nginx-module-0.60.tar.gz -C /usr/src/
​
[root@harry ~]# tar zxvf nginx-1.6.2.tar.gz -C /usr/src/
​
[root@harry ~]# cd /usr/src/nginx-1.6.2/
​
[root@harry nginx-1.6.2# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-file-aio --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-http_ssl_module --with-pcre --add-module=/usr/src/echo-nginx-module-0.60/ &&make &&make install
​
[root@harry nginx-1.6.2# cd
​
[root@harry ~]# ln -s /usr/local/nginx/sbin/* /usr/local/sbin/
​
[root@harry ~] # vi /usr/local/nginx/conf/nginx.conf
​
worker_processes 1;
​
      events {
​
          use epoll;
​
          worker_connections 4096;
​
              }
​
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" ';
​
      access_log logs/access.log main;
​
      sendfile on;
​
      keepalive_timeout 65;
​
server {
​
  listen 192.168.1.78:80;
​
  server_name harry78;
​
  charset utf-8;
​
  access_log logs/harry.access.log main;
​ ​
  location / {
​
       echo "nginx";
​
}
​
}
​
}
​
[root@harry ~]# killall -9 nginx
​
[root@harry ~]# nginx
​
[root@harry ~]# curl 192.168.1.78
​
nginx
​
[root@harry ~]# curl -I 192.168.1.78
​
HTTP/1.1 200 OK
​
Server: nginx/1.6.2
​
Date: Fri, 13 Jul 2018 18:06:42 GMT
​
Content-Type: application/octet-stream
​
Connection: keep-alive
​

CentOSLinux系统Nginx优化的更多相关文章

  1. nginx优化

    此文章非原创,出自鸟哥之手~ http://blog.chinaunix.net/uid-25266990-id-2985541.html 改排版改得多,当然红色部分要注意下,用得较多 ------- ...

  2. 2.Nginx优化

    [教程主题]:Nginx优化 [课程录制]: 创E [主要内容] Nginx 优化 nginx介绍 Nginx是俄罗斯人编写的十分轻量级的HTTP服务器,Nginx,它的发音为"engine ...

  3. Nginx优化具体,应对高并发

     nginx指令中的优化(配置文件) worker_processes 8; nginx进程数,建议依照cpu数目来指定.一般为它的倍数. worker_cpu_affinity 00000001 ...

  4. CentOS6.5 Nginx优化编译配置[续]

    继续上文CentOS6.5 Nginx优化编译配置本文记录有关Nginx系统环境的一些细节设置,有关Nginx性能调整除了配置文件吻合服务器硬件之前就是关闭不必要的服务.磁盘操作.文件描述符.内核调整 ...

  5. nginx优化php-fpm优化 压力测试达到每分150万访问量webbench网站压力

    webbench最多可以模拟3万个并发连接去测试网站的负载能力,个人感觉要比Apache自带的ab压力测试工具好,安装使用也特别方便. 1.适用系统:Linux 2.编译安装:引用wget http: ...

  6. Nginx优化(十七)

    [教程主题]:Nginx优化 [课程录制]: 创E [主要内容] Nginx 优化 nginx介绍 Nginx是俄罗斯人编写的十分轻量级的HTTP服务器,Nginx,它的发音为“engine X”,是 ...

  7. Linu之linux系统基础优化和基本命令

    Linux系统基础优化和基本命令 网络参数设定命令 ifconfig: 查询,设置网卡和ip等参数 ifup,ifdown: 脚本命令,更简单的方式 ip: 符合指令,直接修改上述功能 编辑网卡配置文 ...

  8. Linux系统——Nginx基础

    Nginx是一个开源的,支持高性能.高并发(特别是静态资源)的www服务和代理服务软件,还具有反向代理复杂均衡功能和缓存服务功能,与lvs负载均衡及Haproxy等专业代理软件相比,nginx部署更简 ...

  9. nginx优化配置大全

    由于面试被问到nginx优化做过哪些 后来发现,其实做过的也不少,忘了的更不少,因此写个博客记录一下(里面有一些内容来源于其他作者). 配置文件样例为生产环境样例. 1.nginx基本优化 安装方式有 ...

随机推荐

  1. 一些项目中用到的php函数

    #不为空 if (!empty($_POST)) { } #生成随机数 mt_rand(,)产生999-9999范围间的随机数

  2. scrapy五大核心组件和中间件以及UA池和代理池

    五大核心组件的工作流程 引擎(Scrapy) 用来处理整个系统的数据流处理, 触发事务(框架核心) 调度器(Scheduler) 用来接受引擎发过来的请求, 压入队列中, 并在引擎再次请求的时候返回. ...

  3. 【NOIP2016提高组复赛day2】天天爱跑步

    题目 小 C 同学认为跑步非常有趣,于是决定制作一款叫做<天天爱跑步>的游戏. <天天爱跑步>是一个养成类游戏,需要玩家每天按时上线,完成打卡任务. 这个游戏的地图可以看作一棵 ...

  4. Idea创建多模块依赖Maven项目

    idea 创建多模块依赖Maven项目   本来网上的教程还算多,但是本着自己有的才是自己的原则,还是自己写一份的好,虽然可能自己也不会真的用得着. 1. 创建一个新maven项目 2. 3. 输入g ...

  5. raster导入postgres Windows命令

    cmd命令行 raster2pgsql -s 4326 -I -C -M C:\Users\tt\Downloads\tmean_19_tif\*.tif -F -t 256x256 tmean_19 ...

  6. Linux的目录结构与目录管理

    Linux的目录结构与目录管理 Linux目录结构: 目录创建的规则 FHS 文件系统层次化标准 指定了Linux操作系统,哪些目录是一定要具备的 /boot /bin /sbin /etc /sys ...

  7. Linux培训教程 linux系统下分割大文件的方法

    在linux中分割大文件,比如一个5gb日志文件,需要把它分成多个小文件,分割后以利于普通的文本编辑器读取. 有时,需要传输20gb的大文件,Linux培训 教程件到另一台服务器,也需要把它分割成多个 ...

  8. React Native中集成友盟社会化分享-----童叟无欺

    1.下载所需的jar,下载地址https://developer.umeng.com/sdk/reactnative?spm=a211g2.211692.0.0.28967d238GW6mC 2.将以 ...

  9. CF 149E Martian Strings 后缀自动机

    这里给出来一个后缀自动机的题解. 考虑对 $s$ 的正串和反串分别建后缀自动机. 对于正串的每个节点维护 $endpos$ 的最小值. 对于反串的每个节点维护 $endpos$ 的最大值. 这两个东西 ...

  10. Devexpress MVC DropDownList (持续更新))

    @Html.DevExpress().DropDownEdit(settings => { settings.Name = "psBankCharge"; settings. ...