用Kylin Server打包国密nginx的RPM安装包

本文描述在Kylin Server系统中打包可供系统安装的RPM包;
系统信息:
NAME="Kylin Linux Advanced Server"
VERSION="V10 (Halberd)"
ID="kylin"
VERSION_ID="V10"
PRETTY_NAME="Kylin Linux Advanced Server V10 (Halberd)"
ANSI_COLOR="0;31"
一、生成RPM初始目录

rpmbuild --build-in-place
cd /root/rpmbuild && tree

├── BUILD 源代码解压以后放的位置,只需提供BUILD目录,不用操作
├── BUILDROOT 软件安装的层级,使用install临时安装到这个目录,把这个目录当作根来用,安装完成后目录将被删除
├── RPMS 生成的RPM包的存放位置,不用操作
├── SOURCES 程序内容,需要操作
├── SPECS 控制文件,描述软件包的名称、版本、每一步的具体操作内容等等,需要操作
└── SRPMS SRC格式的RPM包存放位置,不用操作
二、下载源码并合并压缩

cd /opt/ && tar -zxvf tengine-3.1.0.tar.gz
mv tengine-3.1.0 mnginx-1.24.0
unzip Tongsuo-master.zip
/bin/cp -arf Tongsuo-master mnginx/
cd /opt/ && tar -zcvf mnginx-1.24.0.tar.gz mnginx-1.24.0/
cp mnginx-1.24.0.tar.gz /root/rpmbuild/SOURCES/

文件复制完成后数据结构如下图
用Kylin Server打包国密nginx的RPM安装包
上传nginx.spec到对应的SPEC目录后开始构建rpm软件安装包

cd /root/rpmbuild/SPECS
rpmbuild -bb nginx.spec

构建完成后安装包在RPMS目录,成功如下图
用Kylin Server打包国密nginx的RPM安装包
下载安装包到另外一个服务器上测试安装,装完了默认监听443端口,外部访问记得关闭防火墙

iptables -F 

用Kylin Server打包国密nginx的RPM安装包
用Kylin Server打包国密nginx的RPM安装包
用Kylin Server打包国密nginx的RPM安装包
最后附SPEC控制文件和压缩的源码
nginx.spec
mnginx-1.24.0.tar.gz
mnginx-1_24_0-1_ky10_x86_64.rpm
常用命令如下
[root@localhost ~]# systemctl status mnginx.service
● mnginx.service - GM nginx
Loaded: loaded (/usr/lib/systemd/system/mnginx.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2024-12-03 21:01:37 CST; 13min ago
Process: 9670 ExecStart=/opt/mnginx-1.24.0/sbin/nginx (code=exited, status=0/SUCCESS)
Main PID: 9671 (nginx)
Tasks: 2
Memory: 1.5M
12月 03 21:01:37 localhost.localdomain systemd[1]: Starting GM nginx...
12月 03 21:01:37 localhost.localdomain systemd[1]: Started GM nginx.
[root@localhost ~]# mnginx -t
nginx: the configuration file /opt/mnginx-1.24.0/conf/nginx.conf syntax is ok
nginx: configuration file /opt/mnginx-1.24.0/conf/nginx.conf test is successful

标签:none

本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。