linux编译安装nginx及附加选项(AlmaLinux/CentOS/Redhat)

下载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

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值