先用lnmp 脚本安装一遍LNMP,然后再单独编译nginx升级
Openssl 1 2 wget https://github.com/openssl/openssl/releases/download/openssl-3.4.0/openssl-3.4.0.tar.gz tar -vzxf openssl-3.4.0.tar.gz
FancyIndex 1 2 wget https://github.com/aperezdc/ngx-fancyindex/releases/download/v0.5.2/ngx-fancyindex-0.5.2.tar.xz tar -xvJf ngx-fancyindex-0.5.2.tar.xz
brotli 1 2 3 4 5 6 7 8 9 10 11 12 git clone --depth=1 https://github.com/google/ngx_brotli cd ngx_brotli/depsgit clone --depth=1 https://github.com/google/brotli cd brotlimkdir out && cd outcmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF \ -DCMAKE_C_FLAGS="-Os -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections" \ -DCMAKE_CXX_FLAGS="-Ofast -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections" \ -DCMAKE_INSTALL_PREFIX=./installed .. cmake --build . --config Release
Nginx 1 2 3 4 5 6 7 8 9 10 11 12 13 wget https://github.com/nginx/nginx/releases/download/release-1.27.3/nginx-1.27.3.tar.gz tar -vzxf nginx-1.27.3.tar.gz cd nginx-1.27.3./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module \ --with-http_ssl_module --with-http_v2_module --with-http_v3_module --with-http_addition_module \ --with-http_gzip_static_module --with-http_gunzip_module --with-http_sub_module --with-stream \ --with-stream_ssl_module --with-stream_ssl_preread_module --with-stream_realip_module \ --with-http_realip_module --with-openssl=../openssl-3.4.0 \ --with-openssl-opt='enable-weak-ssl-ciphers' --with-ld-opt='-ljemalloc' \ --add-module=../ngx_brotli --add-module=../ngx-fancyindex-0.5.2 make
升级 1 2 3 4 5 mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bakcp objs/nginx /usr/local/nginx/sbin/nginx/usr/local/nginx/sbin/nginx -t make upgrade nginx -V
1 2 3 4 5 nginx version: nginx/1.27.3 built by gcc 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04) built with OpenSSL 3.4.0 22 Oct 2024 TLS SNI support enabled configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_v3_module --with-http_addition_module --with-http_gzip_static_module --with-http_gunzip_module --with-http_sub_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-stream_realip_module --with-http_realip_module --with-openssl=../openssl-3.4.0 --with-openssl-opt=enable-weak-ssl-ciphers --with-ld-opt=-ljemalloc --add-module=../ngx_brotli --add-module=../ngx-fancyindex-0.5.2