下载nginx源码 版本依官网最新版本号为准
wget https://nginx.org/download/nginx-1.24.0.tar.gz
tar zxvf nginx-1.24.0.tar.gz
添加nginx用户及用户组
groupadd nginx
useradd nginx -g nginx -s /sbin/nologin -M
注释:
依赖 openssl和google的brotli
下载依赖到同目录
wget https://www.openssl.org/source/openssl-3.0.13.tar.gz
tar zxvf openssl-3.0.13.tar.gz
git clone https://github.com/google/ngx_brotli.git
cd ngx_brotli
git submodule update --init
安装RTMP流模块
git clone https://github.com/arut/nginx-rtmp-module.git
安装库及编译工具
dnf install perl pcre pcre-devel zlib-devel epel-release gcc gcc-c++ -y
./configure --add-module=../ngx_brotli --add-module=../nginx-rtmp-module --prefix=/etc/nginx --with-http_ssl_module --with-http_gzip_static_module --with-http_stub_status_module --with-pcre --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-http_secure_link_module --with-http_v2_module --with-cc-opt='-O3' --with-openssl=../openssl-3.0.13 --with-openssl-opt='enable-tls1_3' --with-stream=dynamic --with-stream --with-stream_ssl_preread_module --with-http_dav_module --with-ipv6 --user=nginx --group=nginx
make 报错
yum install brotli-devel
apt install libbrotli-dev libpcre2-dev build-essential clang flex bison g++ gawk \
gcc-multilib g++-multilib gettext git libncurses5-dev libssl-dev \
python3-setuptools rsync swig unzip zlib1g-dev file wget
添加nginx服务文件
cd /etc/systemd/system/
vim nginx.service
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
#PIDFile=/etc/nginx/logs/nginx.pid
ExecStartPre=/etc/nginx/sbin/nginx -t
ExecStart=/etc/nginx/sbin/nginx -c /etc/nginx/conf/nginx.conf
ExecReload=/etc/nginx/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target