编译安装
编译安装
dnf install -y gcc make pcre2-devel zlib-devel openssl-devel
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module
make -j$(nproc)
sudo make install
/usr/local/nginx/sbin/nginx -v
/usr/local/nginx/sbin/nginx -tsystemd 托管
systemd 托管
cat > /etc/systemd/system/nginx-local.service <<'EOF'
[Unit]
Description=nginx (local build)
[Service]
ExecStart=/usr/local/nginx/sbin/nginx -g 'daemon off;'
ExecReload=/usr/local/nginx/sbin/nginx -s reload
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload && systemctl enable --now nginx-local与发行版自带 nginx 共存时注意目录与单元名冲突:二选一或明确端口与配置目录。