Skip to main content

centos构建nginx添加quic

1、安装nginx编译环境

dnf install gcc gcc-c++ pcre-devel openssl-devel zlib-devel cmake make go libunwind-devel hg git wget

2、克隆依赖库

git clone https://gitee.com/fenghuolingyun/boringssl.git

3、下载源码并解压

wget https://nginx.org/download/nginx-1.25.4.tar.gz
tar -xf nginx-1.25.4.tar.gz

4、开始编译ssl依赖

  • 配置发布稳定版本 默认使用cmake .. 构建调试版本如果构建中报错添加全局go代理export GO111MODULE=on export GOPROXY=https://mirrors.aliyun.com/goproxy/
cd boringssl
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make

5、编译nginx程序

cd nginx-1.25.4

./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_v3_module --with-cc=c++ --with-cc-opt='-I../boringssl/include -x c' --with-ld-opt='-L../boringssl/build/ssl -L../boringssl/build/crypto'

make

6、编译完成我们替换掉yum源安装的主程序

cd objs && rm -rf /usr/sbin/nginx && cp ./nginx /usr/sbin/nginx

7、全部完成开启服务并且启动

systemctl enable nginx //创建开机启动服务
systemctl restart nginx //重启服务
systemctl disable nginx //移除开机启动
nginx -s reload //重载配置文件

配置文件在/etc/nginx/