FPM制作rpm包
发表于:2026-11-03 作者:千家信息网编辑
千家信息网最后更新 2026年11月03日,#软件信息#FPM github :https://github.com/jordansissel/fpm#FPM documentation :https://fpm.readthedocs.io/
千家信息网最后更新 2026年11月03日FPM制作rpm包
#软件信息
#FPM github :https://github.com/jordansissel/fpm
#FPM documentation :https://fpm.readthedocs.io/en/latest/
#FPM源类型与目标类型
Things that should workSources:gem (even autodownloaded for you)python modules (autodownload for you)pear (also downloads for you)directoriestar(.gz) archivesrpmdebnode packages (npm)pacman (ArchLinux) packagesTargets:debrpmsolarisfreebsdtardirectoriesMac OS X .pkg files (osxpkg)pacman (ArchLinux) packages
FPM常用参数:
-s 指定源类型
-t 指定目标类型
-n 指定包的名字
-v 指定包的版本号
-C 指定打包的相对路径
-d 指定依赖于哪些包
--url URI 给该包添加URL (default: "http://example.com/no-uri-given")
-f 第二次包时目录下如果有同名安装包存在,则覆盖它;
-p :制作的rpm安装包存放路径,不想放在当前目录下就需要指定;
--post-install FILE 软件包安装完成之后所要运行的脚本;
--pre-install FILE 软件包安装完成之前所要运行的脚本;
--post-uninstall FILE 软件包卸载完成之后所要运行的脚本;
--pre-uninstall FILE 软件包卸载完成之前所要运行的脚本;
--prefix: 制作好的rpm包默认安装路径;
--after-remove FILE 软件包卸载完成后要运行的脚本
--before-remove FILE 软件包卸载完成前要卸载的脚本
#安装FPM
[root@KVM_1 ~]# yum install -y ruby rubygems ruby-devel[root@KVM_1 ~]# gem sources --add http://gems.ruby-china.org/ --remove https://gems.ruby-china.org/[root@KVM_1 ~]# gem sources -l*** CURRENT SOURCES ***http://gems.ruby-china.org/[root@KVM_1 ~]#[root@KVM_1 ~]# gem install fpm[root@KVM_1 ~]# yum install -y rpm-build
#编译安装Nginx
[root@KVM_1 ~]# wget http://mirrors.sohu.com/nginx/nginx-1.13.0.tar.gz[root@KVM_1 ~]# tar -xf nginx-1.13.0.tar.gz [root@KVM_1 ~]# cd nginx-1.13.0/[root@KVM_1 nginx-1.13.0]# yum install -y pcre pcre-devel openssl openssl-devel gcc-c++[root@KVM_1 nginx-1.13.0]# useradd -s /usr/sbin/nologin -M nginx[root@KVM_1 nginx-1.13.0]# ./configure --with-http_stub_status_module --with-http_ssl_module --prefix=/usr/local/nginx --user=nginx --group=nginx[root@KVM_1 nginx-1.13.0]# make && make install[root@KVM_1 nginx-1.13.0]# cd[root@KVM_1 ~]# /usr/local/nginx/sbin/nginx [root@KVM_1 ~]# curl -I 192.168.174.134HTTP/1.1 200 OKServer: nginx/1.13.0Date: Wed, 10 May 2017 19:52:20 GMTContent-Type: text/htmlContent-Length: 612Last-Modified: Wed, 10 May 2017 19:50:48 GMTConnection: keep-aliveETag: "59136f18-264"Accept-Ranges: bytes[root@KVM_1 ~]# /usr/local/nginx/sbin/nginx -s quit
#编写软件包安装后要执行的命令的脚本
[root@KVM_1 ~]# cat /root/nginx_init.sh #!/bin/bash useradd -s /sbin/nologin -M nginx echo '[Unit]Description=nginx - high performance web serverDocumentation=http://nginx.org/en/docs/After=network.target remote-fs.target nss-lookup.target [Service]Type=forkingPIDFile=/usr/local/nginx/logs/nginx.pidExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.confExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.confExecReload=/bin/kill -s HUP $MAINPIDExecStop=/bin/kill -s QUIT $MAINPIDPrivateTmp=true [Install]WantedBy=multi-user.target' > /usr/lib/systemd/system/nginx.service[root@KVM_1 ~]#chmod +x /root/nginx_init.sh
#打包rpm
[root@KVM_1 ~]# fpm -s dir -t rpm -n nginx -v 1.13.0 -d 'pcre,pcre-devel,openssl,openssl-devel' --post-install /root/nginx_init.sh -f /usr/local/nginx#参数解释-s 源类型 此处为 目录-t 目标类型 此处为 rpm-n 软件包名 此处为 nginx-v 版本号 此处为 1.13.0-d 依赖包 此处为 pcre,pcre-devel,openssl,openssl-devel--post-install 安装软件包后要执行的脚本 此处为 /root/nginx_init.sh-f 强制覆盖/usr/local/nginx 要被打包的目录##打包完成后会在当前目录生成 rpm包[root@KVM_1 ~]# lsanaconda-ks.cfg nginx-1.13.0.tar.gz nginx_init.sh nginx-1.13.0 nginx-1.13.0-1.x86_64.rpm
#测试
[root@KVM_1 ~]# hostnameKVM_1[root@KVM_1 ~]# scp nginx-1.13.0-1.x86_64.rpm 192.168.174.135:/media/[root@KVM_1 ~]# ssh 192.168.174.135[root@KVM_2 ~]# hostnameKVM_2#配置YUM源[root@KVM_2 ~]# cat /etc/yum.repos.d/local.repo [local]name=localbaseurl=file:///media/gpgcheck=0enabled=1[root@KVM_2 ~]# mount /dev/cdrom /mnt/[root@KVM_2 ~]# cp /mnt/* /media/[root@KVM_2 ~]# cd /media/#更新YUM仓库[root@KVM_2 media]# createrepo -v ./[root@KVM_2 media]# yum makecache[root@KVM_2 media]# yum list | grep nginxnginx.x86_64 1.13.0-1 local pcp-pmda-nginx.x86_64 3.10.6-2.el7 local #安装nginx[root@KVM_2 media]# yum install -y nginx[root@KVM_2 media]# systemctl start nginx[root@KVM_2 media]# systemctl status nginx● nginx.service - nginx - high performance web server Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled) Active: active (running) since Thu 2017-05-11 04:00:07 CST; 12s ago Docs: http://nginx.org/en/docs/ Process: 4681 ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf (code=exited, status=0/SUCCESS) Process: 4679 ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf (code=exited, status=0/SUCCESS) Main PID: 4684 (nginx) CGroup: /system.slice/nginx.service ├─4684 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf └─4685 nginx: worker processMay 11 04:00:07 KVM_2 systemd[1]: Starting nginx - high performance web server...May 11 04:00:07 KVM_2 nginx[4679]: nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is okMay 11 04:00:07 KVM_2 nginx[4679]: nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successfulMay 11 04:00:07 KVM_2 systemd[1]: Started nginx - high performance web server.[root@KVM_2 media]# netstat -lntup | grep 80tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 4684/nginx: master [root@KVM_2 media]# curl -I 192.168.174.135HTTP/1.1 200 OKServer: nginx/1.13.0Date: Wed, 10 May 2017 20:01:14 GMTContent-Type: text/htmlContent-Length: 612Last-Modified: Wed, 10 May 2017 20:14:24 GMTConnection: keep-aliveETag: "591374a0-264"Accept-Ranges: bytes
#至此nginx FPM 打包完成
软件
软件包
脚本
类型
目录
运行
目标
路径
制作
参数
版本
后所
前所
仓库
信息
名字
命令
常用
至此
强制
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
手磨咖啡
互联网高科技
互联网加科技
互联网科技的发展
深圳互联网络科技有限公司
齐家互联网科技
杭州互联网科技公司
互联网科技上市公司
中盈科技互联网信息有限公司
晓花互联网科技有限公司网址
深圳育鹏互联网科技有限公司招聘
滨湖区互联网智能科技产品有哪些
美国互联网科技实力
上海京穆互联网科技有限公司
广西科技产业互联网是什么
西安左小互联网科技有限公司
张家口科技产业互联网平台
求路客互联网科技电话
三亚科技创新互联网基地
陕西彩京云互联网科技有限公司
重生之互联网科技帝国
深圳恒合互联网络科技有限公司
科技企业和互联网企业
深圳科技互联网
天津腾达互联网科技有限公司
区块链结合互联网科技
元气玛特互联网科技公司是外包吗
广州梦谷互联网科技有限公司领导
互联网金融运营模式中的金融科技
互联网科技创业有什么好项目