jemalloc+lua+nginx自动化构建

概述#

nginx在同一操作系统上编译构建好的是可以直接分发的(主要是依赖gcc的版本)

Download:

特点:

  • jemalloc(优化对内存的分配管理)
  • lua (支持lua脚本)
  • nginx-v1.22.0
  • modules(支持session/upstream_check)

部署包结构#

image

编译脚本#

Copy
#!/bin/sh set -e ## define basedir=/servyou/nginx release_bin=${1:-nginx-v1.22.0-bin-c7.tar.gz} ## requirement yum install -y gcc gcc-c++ make patch unzip -q ## unzip cd depends ls *.tar.gz |xargs -n1 tar zxf cd - cd lua ls *.zip |xargs -n1 unzip cd - cd modules ls *.zip |xargs -n1 unzip cd - ls *.tar.gz |xargs -n1 tar zxf ## building jemalloc && lua #jemalloc cd depends/jemalloc* ./autogen.sh ./configure -q make -s -j2 && make -s install_bin install_include install_lib cd - #lua cd lua/luajit* make -s -j2 && make -s install cd - #add ld echo "/usr/local/lib" > /etc/ld.so.conf.d/local.conf ldconfig export LUAJIT_LIB=/usr/local/lib export LUAJIT_INC=/usr/local/include/luajit-2.1 ## build nginx cd nginx* ./configure --prefix=$basedir \ --with-http_ssl_module --with-http_realip_module --with-http_stub_status_module --with-stream --with-ld-opt="-ljemalloc" \ --add-module=./modules/nginx-goodies-nginx-sticky-module \ --add-module=../modules/nginx_upstream_check_module-master \ --add-module=../modules/echo-nginx-module-master \ --add-module=./modules/ngx_http_lua_module \ --add-module=../lua/ngx_devel_kit \ --with-pcre=../depends/pcre-8.37 \ --with-zlib=../depends/zlib-1.2.11 \ --with-openssl=../depends/openssl-1.0.2u make -s && make -s install #copy feature rm -rf $basedir/html cp -a ../feature/* $basedir/ cd - ## release cd $basedir cp -a /usr/local/lib . cd .. tar zcf $release_bin nginx/ echo "building successful!!! $(ls $(dirname $basedir))" #echo '/servyou/nginx/lib' > /etc/ld.so.conf.d/ngx_local.conf #ldconfig

清理编译#

Copy
#!/bin/sh ## define ts=$(date +%F-%T) #2022-08-03-00:45:41 ## lib/include cd /usr/local mv lib{,_$ts} mv include{,_$ts} cd - ## suffix tar.gz | zip cd depends ls -F |egrep /$ |xargs rm -rf cd - cd lua ls -F |egrep /$ |xargs rm -rf cd - cd modules ls -F |egrep /$ |xargs rm -rf cd - ngx_dir=$(ls |grep "nginx" |egrep -v "tar.gz$") rm -rf $ngx_dir echo "clean successful!!!"

使用注意#

使用#

Copy
tar zxf building-nginx-v1.22.0.tar.gz && cd building-nginx* //编译 sh ngx_building.sh 默认构建成果$1 = nginx-v1.22.0-bin-c7.tar.gz sh ngx_building.sh nginx-v1.22.0-bin-c6.tar.gz sh ngx_clean.sh //清理后在次编译

注意: 编译好的二进制发行版本跟系统存在依赖关系,核心就是gcc的支持版本

  • c6就是centos6的发型版本
  • c7就是centos7的发型版本

如何使用构建好的二进制成果#

Copy
echo '/servyou/nginx/lib' > /etc/ld.so.conf.d/ngx_local.conf ldconfig ./sbinx/nginx -t //测试是否可以运行 如果不是默认的prefix则可以指定 -p ./sbinx/nginx -p /opt/nginx -t
posted @   mvpbang  阅读(100)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· AI与.NET技术实操系列(六):基于图像分类模型对图像进行分类
历史上的今天:
2018-08-05 mysql5.6特殊字符问题
2017-08-05 Snipaste截图
点击右上角即可分享
微信分享提示
CONTENTS