NOTE

1.4 编译安装

Nginx 源码编译安装、启动、参数与目录。

Web Server / Nginx更新于 约 1 分钟读完historical

这是历史学习笔记,可能存在过时或不完整的理解。

1. 搭建步骤

1.1. 下载

  • Nginx nginx: download Nginx 官方区分 mainline 与 stable 分支,不再使用“偶数稳定、奇数开发”作为判断规则;下载时以官网当前发布说明为准。

  • 其他依赖的源码

mkdir src
cd src

# 依赖版本变化较快,请从各项目官网获取当前受支持版本。
# 常见依赖包括 PCRE2、zlib、OpenSSL。
# 如果目标是使用 Lua,通常更推荐直接使用 OpenResty,避免手工组合过旧的 LuaJIT/模块版本。

1.2. 安装开发环境

sudo apt update
sudo apt install -y build-essential libpcre2-dev zlib1g-dev libssl-dev

1.3. 编译安装

./configure --prefix="$HOME/software/nginx" \
            --with-threads \
            --with-file-aio \
            --with-http_ssl_module \
            --with-http_v2_module \
            --with-http_realip_module \
            --with-http_gzip_static_module \
            --with-http_auth_request_module \
            --with-http_secure_link_module \
            --with-http_stub_status_module \
            --with-stream \
            --with-stream_ssl_module \
            --with-debug

make -j"$(nproc)"
make install

1.4. 启动

$HOME/software/nginx/sbin/nginx -c $HOME/software/nginx/conf/nginx.conf

2. 查看安装时所选用的参数

nginx -V

3. 目录介绍

4. 参考

正在加载有帮助数量