• nginx安装配置


    mac os

    1. 安装
    brew install  nginx
    
    1. 启动命令位置
      /usr/local/bin/nginx

    2. 配置文件路径
      /usr/local/etc/nginx/nginx.conf

    centos安装nginx

    1. 安装依赖
    yum -y install gcc pcre-devel zlib-devel openssl openssl-devel
    
    1. 下载nginx压缩包
      下载 nginx

    2. 解压缩

    ## 解压
    tar -zxvf nginx-1.9.9.tar.gz
    
    ##进入nginx目录
    cd nginx-1.9.9
    ## 配置
    ./configure --prefix=/usr/local/nginx
    
    # make
    make
    make install
    

    nginx离线安装

    nginx和依赖包
    在 /usr/local/src目录下:

    1. pcre-8.42.tar.gz
    tar -zxvf pcre-8.42.tar.gz
    cd pcre-8.42/
    ./configure
    make
    make install
    
    1. zlib-1.2.11.tar.gz
    tar -zxvf zlib-1.2.11.tar.gz
    cd zlib-1.2.11/
    ./configure
    make
    make install
    
    1. openssl-1.0.2h.tar.gz
    tar -zxvf openssl-1.0.2h.tar.gz
    cd openssl-1.1.0h/
    ./config
    make
    make install
    
    1. nginx-1.14.0.tar.gz
    tar -zxvf nginx-1.14.0.tar.gz
    cd nginx-1.14.0/
    ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-pcre=../pcre-8.42 --with-zlib=../zlib-1.2.11 --with-openssl=../openssl-1.0.2h
    make
    make install
    

    nginx常用命令

    1. 启动
    cd /usr/local/nginx/sbin
    ./nginx
    
    1. 停止
    cd /usr/local/nginx/sbin
    ./nginx -s stop
    
    1. 重新加载
    cd /usr/local/nginx/sbin
    ./nginx -s reload
    

    nginx配置文件

    nginx配置文件在安装目录,/usr/local/nginx/conf/nginx.conf

    nginx配置文件的组成

    从配置文件开始到event块之间的内容,设置一些影响nginx服务器整体运行的配置指令,
    主要包括配置nginx的用户(组)、允许生成的worker process数、进程PID存放路径、日志存放路径和类型以及配置文件的引入等。

    1. 全局快
    worker_processess 1;  # 处理并发的数量
    
    1. event块

    影响nginx与用户的网络连接。

    如:worker_connections 1024; # 最大的连接数量

    worker_connections 1024;  # 最大的连接数量
    
    1. http块
      可包括http全局块、server块
    http{
        xxx;
        server {
            location /{
    
            }
        }
    }
    

    端口开放

    1. 查看
    firewall-cmd --list-all
    
    1. 增加
    firewall-cmd --add-port=80/tcp --permanent
    
    1. 重新加载
    firewall-cmd --reload
    

    配置实例:反向代理

  • 相关阅读:
    千年决心
    编译器及其命令行模式杂谈
    How Microsoft Lost the API War
    再看计算机本科该如何学习
    C++杂记(一)
    C++杂记
    Java IO 学习心得
    VMDq (Virtual Machine Device Queue) in OpenSolaris
    WCHAR and wchar_t 的区别 (zz)
    error C3225: generic type argument for 'T' cannot be 'System::Collections::Generic::KeyValuePair ^',
  • 原文地址:https://www.cnblogs.com/zhuxiang1633/p/13779585.html
Copyright © 2020-2023  润新知