Nginx 筆記

Nginxjavascript

[root@localhost ~]# cat /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.keycss

yum install nginx -y
[root@localhost ~]# nginx -h
nginx version: nginx/1.16.0
Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]java

Options:
-?,-h : this help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-T : test configuration, dump it and exit
-q : suppress non-error messages during configuration testing
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /etc/nginx/)
-c filename : set configuration file (default: /etc/nginx/nginx.conf)
-g directives : set global directives out of configuration filnode


nginx 配置
main:

1.work_processes number|auto

2.work_cpu_affinity auto[cpumask]
CPU MASK:00000001 -->0號cpu
00000010 -->1號cpu
10000000 -->8號cpu
work_cpu_affinity 0001 0010 0100 1000;

[root@localhost nginx]# ps axo pid,cmd,psr,nice |grep nginx
1411 nginx: master process nginx 1 0
1621 nginx: worker process 0 0
1622 nginx: worker process 1 0
2168 grep --color=auto nginx 1 0nginx

3.worker_priority -20to20
4.worker_rlimit_nofile Number(<=65535)


events:

1.worker_connections 15240;
每一個worker時程所能打開的最大併發鏈接數量
總最大併發:worker_processe * worker_connections

2.use method
指明併發鏈接請求的處理方法,默認自動選擇最優方法
use epoll;
3.accept_mutex on|off (互斥)
on指由各個worker輪流處理新請求,off指每一個新請求的到達都會通知(喚醒)全部的worker進程,但只有一個進程能夠
處理,off-形成「驚羣」,影響性能,

調試和定位
1.daemon on|off
是否以守護進程方式運行nignx
2.master_process on|off
是否以master/worker模型運行nginx,默認爲on

http:

1.server {
listen 80;
server_name kanghaibin;
root /usr/local/share/nginx/web;
}

2.tcp_nodelany on|off

3.sendfile on|off
是否啓用sendfileal 功能,在內核中封裝報文直接發達 ,默認off

4.server_tokens on|off
是否響應報文的server首部顯示nginx版本信息 默認是on

5.location

6.try_files

7.client_body_temp_path

8.limit_rate Number 單位bytes/second 限制響應給客戶端的傳輸速率,0爲無限制

9.limit_except GET { #除了192.168.1.0網段容許用GET之外的方法,其實網絡只能用GET方法;
allow 192.168.1.0/24;
deny all;
}

10.dirctio SIZE|off #當文件大於等於給定大小時,同步寫磁盤

11.open_file_cache off;

LRU 最近最少使用算法


12.stub_status
示例:location /status {
stub_status;
allow 192.168.1.0/24;
deny all;
}

壓縮
1.gzip on|off
2.gzip_comp_level Number(1-9)
3.gzip_min_length Length; 啓用壓縮功能的響應報文大小閾值;


示例:
gzip on;
gzip_comp_level 6;
gzip_min_length 64;
gzip_proxide any;
gzip_types text/xml text/css application/javascript;
gzip_vary on;web

相關文章
相關標籤/搜索