相关依赖

    1. yum update
    2. yum install wget
    3. wget http://nginx.org/download/nginx-1.19.1.tar.gz ## nginx 源码包
    4. wget https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz ## 正则会用到
    5. wget https://zlib.net/zlib-1.2.11.tar.gz ##gzip 模块
    6. tar xf 指定文件解压
    1. ./configure --help 查看编译帮助命令
    1. --help print this message
    2. --prefix=PATH nginx总相对路径 下面都可以 默认以相对路径创建
    3. --sbin-path=PATH set nginx binary pathname
    4. --modules-path=PATH set modules path
    5. --conf-path=PATH set nginx.conf pathname
    6. --error-log-path=PATH set error log pathname
    7. --pid-path=PATH set nginx.pid pathname
    8. --lock-path=PATH set nginx.lock pathname
    9. --user=USER nginx配置文件生效启动用户
    10. --with开头都是可以单独指定需要使用的模块
    11. --without 开头指定不需要的模块
    12. 还有一些指定模块路径的参数

    我使用的配置参数

    1. ./configure --prefix=/usr/local/nginx \
    2. --with-pcre=/usr/local/nginx_rely/rely/pcre-8.44 \
    3. --with-zlib=/usr/local/nginx_rely/rely/zlib-1.2.11 \
    4. --with-http_ssl_module \
    5. --with-http_image_filter_module \
    6. --with-http_stub_status_module

    期间根据环境可能需要安装下面三个东西

    1. yum -y install gcc gcc-c++ openssl openssl-devel gd gd-devel

    出现这样 差不多就检测成功了

    nginx 学习 1-编译 - 图1

    1. make 编译 生成Makefile
    2. make install

    去安装目录启动

    nginx 学习 1-编译 - 图2

    设置软连接

    1. ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
    2. nginx -h 查看具体命令
    3. 注意:请在运行 nginx 时,使用绝对路径。因为热部署USR2是通过绝对路径寻找