centos构建nginx添加quic
1、安装nginx编译环境
dnf -y install \
gcc \
gcc-c++ \
pcre-devel \
openssl-devel \
zlib-devel \
cmake \
make \
go \
libunwind-devel \
git \
wget
如果需要构建全模块rpm包环境使用下面:
dnf -y install \
git \
gcc \
gcc-c++ \
make \
rpm-build \
tar \
golang \
cmake \
libunwind-devel \
pcre2-devel \
krb5-devel \
libedit \
libxml2-devel \
libxslt-devel \
gd-devel \
libmaxminddb \
perl-ExtUtils-Embed \
perl-devel \
c-ares-devel \
openssl-devel \
re2-devel \
boost-devel \
libstdc++-devel \
yaml-cpp-devel \
rake \
brotli-devel \
which \
libatomic \
libedit-devel \
libmaxminddb-devel \
libstdc++-static \
lua-devel \
perl-macros \
xz
2、克隆依赖库
git clone https://gitee.com/fenghuolingyun/boringssl.git
3、下载源码并解压
wget https://nginx.org/download/nginx-1.27.3.tar.gz
tar -xf nginx-1.27.3.tar.gz
4、开始编译ssl依赖
- 配置发布稳定版本,默认使用
cmake ..
构建调试版本。如果构建中报错,添加全局go代理export GO111MODULE=on export GOPROXY=https://mirrors.aliyun.com/goproxy/
- 新增参数
-DOPENSSL_SMALL=1
优化构建完成后的二进制文件大小,注意最新版本需要配套gcc 10.0+
以上版本。
cd boringssl && \
mkdir build && \
cd build && \
cmake -DOPENSSL_SMALL=1 -DCMAKE_BUILD_TYPE=Release .. && \
make -j $(nproc)
5、进入nginx源码目录
cd nginx-1.27.3
6、配置构建参数
./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'
7、开始编译nginx
make -j $(nproc)
8、编译完成我们替换掉yum源安装的主程序
cd objs && \
rm -rf /usr/sbin/nginx && \
cp ./nginx /usr/sbin/nginx