麒麟V10离线无外网,源码编译 Tengine‑3.1.0及OpenResty-1.21.4.1 📅 2026/8/19 12:43:49 麒麟V10离线无外网源码编译 Tengine‑3.1.0操作系统Kylin Linux Advanced Server release V10 (Halberd) 麒麟V10CPUx86_64gcc7.3.0离线无外网源码编译 Tengine‑3.1.0需要4个tar.gz包tengine‑3.1.0.tar.gzopenssl‑1.1.1f.tar.gzpcre‑8.45.tar.gzzlib‑1.2.13.tar.gz所有压缩包先上传到服务器目录/root/softs步骤1进入存放压缩包目录cd/root/softsls-lls输出必须看到4个tar.gz压缩包没有就先上传过来。步骤2解压tengine主包tar-zxvftengine-3.1.0.tar.gz解压完成生成目录/root/softs/tengine-3.1.0步骤3进入tengine源码目录cdtengine-3.1.0步骤4把3个依赖包直接解压到当前tengine源码目录里面重点tar-zxvfopenssl-1.1.1f.tar.gztar-zxvfpcre-8.45.tar.gztar-zxvfzlib-1.2.13.tar.gz执行ls校验当前目录下必须出现这3个文件夹ls# 输出里面要有 openssl-1.1.1f pcre-8.45 zlib-1.2.13../代表回到上一级/root/softs去找压缩包解压释放到当前tengine‑3.1.0目录。❗不要单独在外面解压依赖configure会找不到。步骤5configure配置和正式环境参数完全一致cd/root/softs/tengine-3.1.0 ./configure--prefix/opt/nginx --with-http_v2_module --with-stream\--with-openssl./openssl-1.1.1f\--with-pcre./pcre-8.45\--with-zlib./zlib-1.2.13无报错再往下走出现error代表依赖包路径不对或者gcc缺失。步骤6编译只编译不安装make时间几十秒~几分钟不要中途中断。步骤7安装输出程序到/opt/nginxmakeinstall⚠️如果/opt/nginx旧版本存在会覆盖正式环境测试环境可以执行生产环境先备份旧目录。步骤8验证版本确认和正式环境一模一样/opt/nginx/sbin/nginx-V常用启停命令# 检查配置文件语法 /opt/nginx/sbin/nginx -t # 启动 /opt/nginx/sbin/nginx # 查看运行进程 ps -ef | grep nginx # 重载配置 /opt/nginx/sbin/nginx -s reload # 停止 /opt/nginx/sbin/nginx -s stop目录区分总结/root/softs/tengine‑3.1.0源码目录解压、configure、make在这里干活/opt/nginx运行程序目录业务实际跑的程序二进制、conf配置、日志都在这里本系统不要yum安装nginxTengine已经内置nginx内核二者互斥。随便跑一个html测试步骤1先确认默认站点目录Tengine默认网页目录/opt/nginx/html里面自带index.html默认首页先启动服务访问默认页验证。# 1.校验配置语法 /opt/nginx/sbin/nginx -t # 输出 nginx.conf syntax is ok 才继续 # 2.启动Tengine /opt/nginx/sbin/nginx # 查看进程确认启动成功 ps -ef | grep nginx步骤2快速自定义一个测试HTML页面# 写入简单测试页面 cat /opt/nginx/html/test.html EOF !DOCTYPE html html head meta charsetutf-8 titleTengine离线部署测试页/title /head body h1✅ Tengine 3.1.0 离线编译部署成功/h1 pOpenSSL 1.1.1f | GCC7.3.0 | 麒麟V10离线环境/p p测试页面访问正常/p /body /html EOF步骤3访问方式先看服务器监听端口默认配置是80端口浏览器访问http://服务器IP/test.html示例http://192.168.174.10/test.html默认首页http://192.168.174.10常见排查点访问失败时检查防火墙放行80端口麒麟V10# 临时放行 firewall-cmd --add-port80/tcp # 永久放行 firewall-cmd --permanent --add-port80/tcp firewall-cmd --reload若80端口被占用修改/opt/nginx/conf/nginx.conf里的listen端口改完执行/opt/nginx/sbin/nginx -s reload重载即可确认服务器和你的电脑网络互通能ping通服务器IP重载/停止备用命令# 修改页面/配置后平滑重载 /opt/nginx/sbin/nginx -s reload # 停止服务 /opt/nginx/sbin/nginx -s stop单独编译一套OpenResty独立安装Tengine 和 OpenResty 不要混装混用Tengine阿里Nginx分支不带LuaJIT/lua‑nginx‑moduleOpenRestyNginxLuaJIT全套专门跑Lua业务逻辑两者都是nginx内核编译参数、模块不一样二进制不能互换。方案单独编译一套OpenResty独立安装目录不和/opt/nginx冲突端口错开不要覆盖Tengine。##准备离线包清单4个放到 /root/softsopenresty‑1.21.4.1.tar.gz openssl‑1.1.1w.tar.gz # 建议用1.1.1w也可以沿用你Tengine的1.1.1f pcre‑8.45.tar.gz zlib‑1.2.13.tar.gz版本匹配openresty‑1.21.4.1 只支持 openssl‑1.1.1系列不要openssl3.x目录结构/root/softs/ ├─ tengine-3.1.0/ # Tengine源码已编译完成 ├─ openresty-1.21.4.3/ # OpenResty主源码目录 │ ├─ openssl-1.1.1f/ # 依赖解压在此目录内 │ ├─ pcre-8.45/ │ └─ zlib-1.2.13/ # 外层仅保留原始压缩包备份不存放解压后的依赖文件夹 ├─ openresty-1.21.4.3.tar.gz ├─ openssl-1.1.1f.tar.gz ├─ pcre-8.45.tar.gz └─ zlib-1.2.13.tar.gz步骤1进入softs解压OpenResty主源码cd /root/softs tar -zxvf openresty-1.21.4.3.tar.gz cd openresty-1.21.4.3步骤2复制3个依赖文件夹到当前源码目录关键避免上级路径报错cp -r ../openssl-1.1.1f ./ cp -r ../pcre-8.45 ./ cp -r ../zlib-1.2.13 ./ # 校验ls能直接看到三个依赖文件夹即成功 ls步骤3执行configure静态编译配置直接复制整段运行./configure \ --prefix/opt/openresty \ --with-pcre./pcre-8.45 \ --with-pcre-jit \ --with-zlib./zlib-1.2.13 \ --with-openssl./openssl-1.1.1f \ --with-http_v2_module \ --with-stream \ --with-http_stub_status_module \ --with-http_realip_module \ --with-http_gzip_static_module无error报错再继续下一步有报错优先检查依赖文件夹是否在当前目录步骤4多核编译 安装make -j$(nproc) make install步骤5编译结果验证# 查看内嵌依赖版本、编译模块 /opt/openresty/nginx/sbin/nginx -V # 校验LuaJIT环境正常 /opt/openresty/bin/resty -V步骤6修改配置错开端口添加Lua测试接口vim /opt/openresty/nginx/conf/nginx.conf找到默认listen 80;改为listen 8080;在server块内追加测试片段location /lua-test { content_by_lua_block { ngx.header.content_type text/html;charsetutf-8 ngx.say(h1✅ OpenResty部署成功/h1) } }步骤7配置校验 启动服务# 语法校验必须ok /opt/openresty/nginx/sbin/nginx -t # 启动OpenResty /opt/openresty/nginx/sbin/nginx # 防火墙放行8080端口 firewall-cmd --permanent --add-port8080/tcp firewall-cmd --reload步骤8访问验证浏览器访问http://192.168.174.10:8080/lua-test页面正常输出即部署完成后续日常运维命令区分两套服务全程写全路径Tengine原有/opt/nginx/sbin/nginx -t # 检查配置 /opt/nginx/sbin/nginx -s reload # 平滑重载 /opt/nginx/sbin/nginx -s stop # 停止OpenResty新部署/opt/openresty/nginx/sbin/nginx -t /opt/openresty/nginx/sbin/nginx -s reload /opt/openresty/nginx/sbin/nginx -s stop可选进阶配置开机自启systemd服务创建服务文件vim /usr/lib/systemd/system/openresty.service写入内容[Unit] DescriptionOpenResty Service Afternetwork.target [Service] Typeforking PIDFile/opt/openresty/nginx/logs/nginx.pid ExecStart/opt/openresty/nginx/sbin/nginx ExecReload/opt/openresty/nginx/sbin/nginx -s reload ExecStop/opt/openresty/nginx/sbin/nginx -s stop PrivateTmptrue [Install] WantedBymulti-user.target生效开机自启systemctl daemon-reload systemctl enable --now openresty避坑重点两套nginx二进制独立禁止互相拷贝sbin/nginx文件不要把两个sbin同时加入全局PATH运维始终用全路径避免混淆全程静态编译本地依赖离线环境无需外网。