Ubuntu21编译安装tengine
安装 编译 tengine
2023-06-13 09:11:39 时间
前言
服务器内部署了很多容器业务,但是许多业务都是需要用80端口对外发布的,会端口占用无法正常运行。 所以决定使用nginx去反向代理对应服务,这样,就可以用80端口发布多个业务。业务容器映射至不同端口上,实现业务需求
为什么选择tengine
tengine是淘宝团队基于nginx二次开发的web服务器项目,针对大访问量网站的需求,添加了很多高级功能和特性
tengine具备什么特性
- 继承Nginx-1.18.0的所有特性,兼容Nginx的配置;
- 支持HTTP的CONNECT方法,可用于正向代理场景;
- 支持异步OpenSSL,可使用硬件如:QAT进行HTTPS的加速与卸载;
- 增强相关运维、监控能力,比如异步打印日志及回滚,本地DNS缓存,内存监控等;
- Stream模块支持server_name指令;
- 更加强大的负载均衡能力,包括一致性hash模块、会话保持模块,还可以对后端的服务器进行主动健康检查,根据服务器状态自动上线下线,以及动态解析upstream中出现的域名;
- 输入过滤器机制支持。通过使用这种机制Web应用防火墙的编写更为方便;
- 支持设置proxy、memcached、fastcgi、scgi、uwsgi在后端失败时的重试次数;
- 动态脚本语言Lua支持。扩展功能非常高效简单;
- 支持按指定关键字(域名,url等)收集Tengine运行状态;
- 组合多个CSS、JavaScript文件的访问请求变成一个请求;
- 自动去除空白字符和注释从而减小页面的体积
- 自动根据CPU数目设置进程个数和绑定CPU亲缘性;
- 监控系统的负载和资源占用从而对系统进行保护;
- 显示对运维人员更友好的出错信息,便于定位出错机器;
- 更强大的防攻击(访问速度限制)模块;
- 更方便的命令行参数,如列出编译的模块列表、支持的指令等;
- 支持Dubbo协议;
- 可以根据访问文件类型设置过期时间; ...
上手安装tengine
1. 环境介绍:
服务器系统版本 | 内核版本 | 服务器厂商 |
---|---|---|
Ubuntu21.10 | 5.13.0-28-generic | 腾讯云轻量服务器 |
2. 下载源码包
3. 解压源码包
tar xf tengine-2.3.3.tar.gz
tar xf pcre-8.37.tar.gz
4. 编译pcre
cd pcre-8.37
./configure
# 报错缺少 C 编译环境
apt update
apt install g++ -y
# 重新编译
./configure
make && make install
cd ~
5. 编译安装tengine
cd tengine-2.3.3/
./configure --prefix=/usr/local/tengine \
--sbin-path=/usr/sbin/nginx \
--modules-path=/usr/lib/tengine/modules \
--conf-path=/usr/local/tengine/conf/nginx.conf \
--error-log-path=/var/log/tengine/error.log \
--http-log-path=/var/log/tengine/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=root \
--group=root \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-http_xslt_module=dynamic \
--with-http_image_filter_module=dynamic \
--with-http_geoip_module=dynamic \
--with-threads \
--with-stream \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-stream_realip_module \
--with-stream_geoip_module=dynamic \
--with-http_slice_module \
--with-mail \
--with-mail_ssl_module \
--with-compat \
--with-http_v2_module \
--add-module=modules/ngx_http_upstream_check_module \
--add-module=modules/ngx_http_upstream_session_sticky_module \
--with-openssl=/usr/local/openssl
# 报错找不到openssl环境,编译一下openssl
wget https://mirrors.cloud.tencent.com/openssl/source/openssl-1.1.1m.tar.gz
tar xf openssl-1.1.1m.tar.gz
cd openssl-1.1.1m/
./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl no-ssl2
make && make install
cat << eof >> /etc/profile.d/openssl.sh
export PATH=/usr/local/openssl/bin:\$PATH
export LD_LIBRARY_PATH=/usr/local/openssl/lib
export LC_ALL="en_US.UTF-8"
export LDFLAGS="-L/usr/local/openssl/lib -Wl,-rpath,/usr/local/openssl/lib"
eof
source /etc/profile.d/openssl.sh
# 继续编译tengine,再次报错,缺失zlib库
apt install zlib1g-dev -y
# 报错缺失libxml2/libxslt
apt install libxslt1-dev libxml2-dev -y
# 报错缺失gd库
apt install libgd-dev -y
# 报错缺失 geoip 库
apt install libgeoip-dev -y
# 接下来没有报错了,configure完成后,继续安装
make && make install
# 编译报错,make[1]: *** [objs/Makefile:1987: /usr/local/openssl/.openssl/include/openssl/ssl.h] Error 127
# 修改编辑配置文件
vim auto/lib/openssl/conf
CORE_INCS="$CORE_INCS $OPENSSL/.openssl/include"
CORE_DEPS="$CORE_DEPS $OPENSSL/.openssl/include/openssl/ssl.h"
CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libssl.a"
CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libcrypto.a"
# 修改为
CORE_INCS="$CORE_INCS $OPENSSL/include"
CORE_DEPS="$CORE_DEPS $OPENSSL/include/openssl/ssl.h"
CORE_LIBS="$CORE_LIBS $OPENSSL/lib/libssl.a"
CORE_LIBS="$CORE_LIBS $OPENSSL/lib/libcrypto.a"
# 重新编译安装一遍,安装就完成了
6. 检查tengine是否可用了
nginx -t
# 报错,/var/cache/nginx/client_temp 不存在,手动创建一下目录
mkdir -p /var/cache/nginx/
大功告成
编译过程中遇到许多依赖缺失,Ubuntu系统与centos不一样,centos下可以直接安装缺失依赖,Ubuntu下依赖包名字是不同的,如gcc-c++,centos可以直接安装,Ubuntu需要安装g++。 后续可以配置tengine,将业务反向代理出去,统一使用80端口发布,用域名区分业务。
相关文章
- Busybox编译安装「建议收藏」
- 麒麟系统V10 SP2 Agent2 6.0.8 编译安装
- Windows10安装免安装版redis
- Adobe Acrobat XI Pro软件安装教程pdf编辑器全版本下载
- LFS 8.4 的编译与安装:ubuntu 18.04 宿主系统
- Centos7 安装 Redis 6.0.8 遇坑记(Redis 编译安装)
- Maven简介和安装(配置中央仓库和本地仓库,IDEA配置Maven)
- 高可用 - 04 Keepalived编译安装与配置
- 【Linux 内核】编译 Linux 内核 ③ ( 安装 ncurses | 安装 flex | 安装 bison | 打开 Linux 内核编译配置菜单 )
- 安装配置:Linux环境下安装配置Kafka
- MYSQL安装路径:精准设置指南(mysql的安装路径设置)
- Linux下编译安装FFmpeg(linux编译ffmpeg)
- MySQL RPM包安装过程指南(mysqlrpm包安装)
- BiLinux安装:从零开始(biolinux安装)
- 【菜鸟文章】ubuntu 11.04 natty 安装 flashplayer插件
- 安装Redis:从源码编译到运行(编译安装redis)
- Oracle安装与配置指南(oracle安装配置教程)
- Linux 安装与编译工具链指南(linux安装编译工具链)
- 系统刻录u盘,安装Linux系统(u盘刻录linux)
- 如何在 Linux 中不安装软件测试一个软件包
- WDCP软件编译安装脚本分析大全
- Linux源码安装指南: 从编译到安装一篇搞定(linux下源码安装)
- Linux 中文安装:轻松实现本地化环境(linux安装中文语言)
- 如何在Linux中安装RTX?(linuxrtx安装)
- DRBD的编译安装与配置文档
- 快来学会如何安装Redis扩展!(怎么安装redis扩展)
- Linux镜像安装:简单快捷的系统部署方式(linux 镜像 安装)
- MSSQL编译安装:从入门到精通(mssql编译 安装)
- Redis集群安装指南安装在本地还是云端(redis集群安装在哪里)
- squid3缓存服务器编译安装和高命中率配置示例
- Linux下编译安装MySQL-Python教程
- PHP编译安装中遇到的两个错误和解决方法