Stories

Detail Return Return

Tengine-rpm 基於Tengine 3.1深度定製優化 - Stories Detail

Tengine RPM English

Tengine是亞洲最大的電子商務網站淘寶網推出的高性能的HTTP和反向代理web服務器。它基於 Nginx HTTP 服務器,擁有許多高級功能。事實證明,Tengine 在淘寶網、天貓、優酷、阿里速賣通和阿里雲等世界前100強網站上非常穩定、高效。

簡言之,Tengine是一個具有一些高級功能的 Nginx 發行版。Tengine官方沒有提供RPM包,這裏提供非官方的經過優化編譯並集成LuaJIT、ModSecurity、geoip2等多種常用模塊的Tengine RPM包,方便用户在目標服務器上快速安裝配置web服務器。

這是基於官方包https://tengine.taobao.org/download/tengine-3.1.0.tar.gz 製作的rpm包,您可免費下載並安裝使用。

目前僅先推出基於almalinux 9.5的rpm包,同樣可用於Red Hat Enterprise Linux (RHEL) 及其衍生產品,如CentOS Linux、Rocky Linux。

如何下載?

https://github.com/eagleos/tengine-rpm/releases

https://tengine-rpm.sourceforge.io

如何安裝?

  • 手工安裝

rpm -Uvh tengine-3.1.0-1.el9.x86_64.rpm

如:

[root@EagleOS ~]# rpm -ivh tengine-3.1.0-1.el9.x86_64.rpm
錯誤:依賴檢測失敗:
geolite2-city < 20250331 被 tengine-3.1.0-1.el9.x86_64 取代
geolite2-country < 20250331 被 tengine-3.1.0-1.el9.x86_64 取代
[root@EagleOS ~]# rpm -Uvh tengine-3.1.0-1.el9.x86_64.rpm
Verifying...                          ################################# [100%]
準備中...                          ################################# [100%]
正在升級/安裝...
1:tengine-3.1.0-1.el9              ################################# [ 33%]
正在清理/刪除...
2:geolite2-country-20191217-6.el9  ################################# [ 67%]
3:geolite2-city-20191217-6.el9     ################################# [100%]

如下圖所示:

如何安裝tengine-rpm

  • 在線安裝
dnf copr enable xmdoor/tengine-rpm
dnf -y install tengine

如下圖所示:

copr安裝tengine-rpm

配置説明

  • nginx配置文件位於:/app/nginx/conf
  • 安裝後會自動啓動nginx服務,手工重啓服務命令:systemctl restart nginx,重載配置命令:systemctl reload nginx
  • 安裝rpm包過程中,會自動檢測目標服務器cpu核數,對nginx配置進行自動優化配置處理
  • 對於目標服務器默認站點,在nginx.conf中對境外服務器默認禁止訪問,以節省服務器相關訪問資源。您如果需要開放此訪問,可更改此文件,刪除如下配置語句即可:

    if ($ip_deny) {
    return 503;
    }
  • 支持lua語法,相關測試語句請查看nginx.conf中配置,可修改相關配置進行測試
  • vhost.conf為站點配置示例,默認未加載,可仿之修改並啓動
  • 本rpm包編譯參數如下:

    [root@EagleOS ~]# nginx -V
    Tengine version: Microsoft-IIS/3.1.0
    nginx version: Microsoft-IIS/8.5/1.24.0
    built by gcc 11.5.0 20240719 (Red Hat 11.5.0-5) (GCC)
    built with OpenSSL 3.2.2 4 Jun 2024
    TLS SNI support enabled
    configure arguments: --prefix=/app/nginx --sbin-path=/usr/sbin/nginx --with-http_ssl_module --with-ld-opt=-lpcre --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-ld-opt=-ljemalloc --with-jemalloc --with-stream --with-stream_ssl_module --with-stream_realip_module --with-stream_ssl_preread_module --with-debug --with-compat --with-file-aio --with-mail --with-mail_ssl_module --with-pcre --with-pcre-jit --with-threads --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_gunzip_module --with-http_image_filter_module --with-http_mp4_module --with-http_random_index_module --with-http_secure_link_module --with-http_sub_module --with-http_v2_module --with-http_addition_module --with-luajit-inc=/usr/include/luajit-2.1 --with-luajit-lib=/usr/lib64 --without-http_upstream_keepalive_module --add-module=modules/ngx_backtrace_module --add-module=modules/ngx_debug_pool --add-module=modules/ngx_debug_timer --add-module=modules/ngx_http_concat_module --add-module=modules/ngx_http_footer_filter_module --add-module=modules/ngx_http_reqstat_module --add-module=modules/ngx_http_slice_module --add-module=modules/ngx_http_trim_filter_module --add-module=modules/ngx_http_upstream_check_module --add-module=modules/ngx_http_upstream_dynamic_module --add-module=modules/ngx_http_upstream_dyups_module --add-module=modules/ngx_http_upstream_keepalive_module --add-module=modules/ngx_http_upstream_session_sticky_module --add-module=modules/ngx_http_upstream_vnswrr_module --add-module=modules/ngx_http_user_agent_module --add-module=modules/ngx_multi_upstream_module --add-module=modules/ngx_slab_stat --add-module=../ngx_cache_purge-2.5.3 --add-module=../ngx_brotli --add-module=../nginx-module-vts-0.2.4 --add-module=../ngx_http_geoip2_module --add-module=../lua-nginx-module-0.10.28 --add-module=../ModSecurity-nginx-master --with-cc-opt='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --with-ld-opt='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,-E'

FAQ

  • 1.為何使用rpm -Uvh而不是rpm -ivh

答:如果目標服務器已經安裝了系統默認的geolite2-city和geolite2-country,則其中的IP數據庫文件是2019年過舊的數據庫,本rpm包中包含同樣路徑及名稱的IP數據庫文件(2025.03.31官方maxmind.com最新數據庫),會覆蓋安裝,所以需要使用rpm -Uvh進行升級安裝。

user avatar hppyvyv6 Avatar u_16077267 Avatar vivo_tech Avatar tencent_blueking Avatar gaodadepijiu Avatar leixue Avatar sofastack Avatar selectdb Avatar east4ming Avatar meirenlideshuizhurou Avatar
Favorites 10 users favorite the story!
Favorites

Add a new Comments

Some HTML is okay.