# Nginx 基础
# 基础
版本:
- mainLine
 - stable
 
基于 Nginx 的扩展应用
- Tengine (淘宝)
 - OpenRetry
 
# Nginx 的主要使用场景
- 静态资源服务
- 通过本地文件系统提供服务
 
 - 反向代理服务
- 缓存
 - 负载均衡
 - 可靠性能
 
 - API 服务
 
# 优点
- 高并发,高性能
 - 可扩展性好
 - 高可靠性
 - 热部署
 - BSD 许可证
 
# 组成
- Nginx 二进制可执行文件
 - Nginx.conf 配置文件
 - access.log 访问日志
 - error.log 错误日志
 
# 配置文件
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
        worker_connections 768;
        # multi_accept on;
}
http {
    ##
    # Basic Settings
    ##
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;
    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;
    include /etc/nginx/mime.types;
    default_type application/octet-stream;
    ##
    # SSL Settings
    ##
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;
    ##
    # Logging Settings
    ##
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;
    ##
    # Gzip Settings
    ##
    gzip on;
    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
    ##
    # Virtual Host Configs
    ##
    include /etc/nginx/conf.d/*.conf;
    # include /etc/nginx/sites-enabled/*;
}
# 模块
- events NGX_EVENT_MODULE
 - http
 - core: NGX_CORE_MODULE
 - errlog
 - stream
 - openssl
 - thread_pool
 
# 容器
- 数组
 - 链表
 - 队列
 - 哈希表
 - 红黑树
 - 基数树
 
# 命令
//测试配置
nginx -t
//停止服务 立即停止
nginx -s stop
//退出 优雅停止
nginx -s quit
//热重载
nginx -s reload
//版本
nginx -v
//指定配置文件目录
nginx -c path
//查看Nginx服务的状态
systemctl status nginx.service
//Nginx启动
systemctl start nginx.service
//Nginx停止
systemctl stop nginx.service
← MongoDB 用户 Nginx FAQ →