• nginx安装与配置--基础


    nginx官网右侧download-->Pre-Built Packages栏目中点stable and mainline

    改/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.key
    module_hotfixes=true

    列出仓库yum repolist

    列出nginx版本yum list nginx

    安装yum install -y nginx

    查看版本nginx -v 

    查看配置文件nginx -V

    systemctl enable nginx    

    查看整体目录结构和应用rpm -ql nginx

    主配:

      /etc/logrotate.d/nginx
      /etc/nginx
      /etc/nginx/conf.d
      /etc/nginx/conf.d/default.conf

      /etc/nginx/nginx.conf

    cgi/fastcgi/uwcgi等配置文件:
      /etc/nginx/fastcgi_params

           /etc/nginx/scgi_params

      /etc/nginx/uwsgi_params

    编码转换映射文件

      /etc/nginx/koi-utf
      /etc/nginx/koi-win

      /etc/nginx/win-utf

    http协议的content-tyoe与扩展名
      /etc/nginx/mime.types

    配置系统守护进程管理器

      /usr/lib/systemd/system/nginx-debug.service

        systemctl reload nginx
      /usr/lib/systemd/system/nginx.service

    终端管理命令
      /usr/sbin/nginx

        nginx -s reload
      /usr/sbin/nginx-debug

    帮助文档
      /usr/share/doc/nginx-1.16.1
      /usr/share/doc/nginx-1.16.1/COPYRIGHT
      /usr/share/man/man8/nginx.8.gz

    模块目录
      /usr/share/nginx
      /usr/share/nginx/html
      /usr/share/nginx/html/50x.html
      /usr/share/nginx/html/index.html

    缓存
      /var/cache/nginx

    日志
      /var/log/nginx

    未查部分

     

    /etc/nginx/modules

    /etc/sysconfig/nginx
    /etc/sysconfig/nginx-debug


    /usr/lib64/nginx
    /usr/lib64/nginx/modules
    /usr/libexec/initscripts/legacy-actions/nginx
    /usr/libexec/initscripts/legacy-actions/nginx/check-reload
    /usr/libexec/initscripts/legacy-actions/nginx/upgrade

    压测ab:yum -y install httpd-tools

    nginx.conf文件中

    ------------------------------------------------------------------------------------------------

     coremodule核心模块:

    user nginx;          #nginx进程所使用的用户

    worker_processes 1;      #nginx运行的work进程数量(建议与cpu核心一致或者auto)

    error_log /log/nginx/error.log   #日志位置

     pid /var/run/nginx.pid      #nginx启动后生成的pid文件和 ps -aux|grep nginx的端口一致

    events事件模块         #nginx服务运行后产生的pid进程号

    events {
    worker_connections 1024;   #每个worker进程支持最大连接数

    use epool;          #事件启动模块,epool默认
    }


    http {                 #内核模块   公共配置定义
    include /etc/nginx/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 /var/log/nginx/access.log main;

    sendfile on;
    #tcp_nopush on;

    keepalive_timeout 65;      #长连接时间

    #gzip on;

    include /etc/nginx/conf.d/*.conf;       #附加配置文件
    }

    默认附件配置文件----主机

    egrep -v '#|^$' /etc/nginx/conf.d/default.conf
    server {
    listen 80;            #监听端口
    server_name localhost;      #域名名称
    location / {            #指定相对跟目录位置
    root /usr/share/nginx/html;     #主机根目录
    index index.html index.htm;    #主机匹配先后后缀
    }
    error_page 500 502 503 504 /50x.html;  #错误跳转代码
    location = /50x.html {          
    root /usr/share/nginx/html;        #跳转页面
    }
    }

    语法测试nginx -t

    重载服务systemctl reload nginx/nginx -s reload

    排错看日志 tail -n 10 /var/log/nginx/error.log

    ro

    动态监测日志

    > /var/log/nginx/error.log 

    tail -f /var/log/nginx/error.log

     

  • 相关阅读:
    移动网络介绍
    统一导航路由方案
    负载均衡汇总
    Openfire部署和配置说明
    CDN技术介绍
    流媒体
    WebSocket和HTTP的区别与联系
    zabbix 邮件报警
    Linux系统故障-Repair filesystem
    redhat 6.8 配置yum源
  • 原文地址:https://www.cnblogs.com/Leaders543/p/12491075.html
Copyright © 2020-2023  润新知