基于FPM制作RPM软件包!
工作中有如下情况需要将文件打包rpm:
- 避免重复工作,将源码程序打包为rpm
- 使用yum发布项目,项目打包为rpm
- 将自己写好的程序打包为rpm,提供给用户下载
- 其他
以前打包rpm是一个非常复杂的一件事情,自从有了fpm,打包rpm就和tar打包文件一样

一:搭建Epel和Base Yum 源
[root@localhost ~]# rz -E //导入epel-release-latest-7.noarch.rpm包
z waiting to receive.**B0100000023be50
[root@localhost ~]# ls
anaconda-ks.cfg nginx-1.16.0.tar.gz 模板 下载
date original-ks.cfg 视频 音乐 nginx-1.15.9.tar.gz
epel-release-latest-7.noarch.rpm website-1.0.1-1.x86_64.rpm 图片 桌面
initial-setup-ks.cfg 公共 文档
[root@localhost ~]# rpm -ivh epel-release-latest-7.noarch.rpm //安装epel-release-latest-7.noarch.rpm
警告:epel-release-latest-7.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID 352c64e5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:epel-release-7-11 ################################# [100%]
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Base.repo CentOS-fasttrack.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-Media.repo epel.repo
CentOS-Debuginfo.repo CentOS-Sources.repo epel-testing.repo
[root@localhost yum.repos.d]# yum clean all && yum makecache
二:安装ruby环境和gem命令FPM
[root@localhost yum.repos.d]# yum -y install rubygems ruby-devel
[root@localhost yum.repos.d]# gem update --system //升级rubygems版本,此处会报错
Updating rubygems-update
Fetching: rubygems-update-3.0.6.gem (100%)Fetching: rubygems-update-3.0.6.gem
ERROR: Error installing rubygems-update:
rubygems-update requires Ruby version >= 2.3.0. //他报多少版本的错误就安装多少版本的
ERROR: While executing gem ... (NoMethodError)
undefined method `version' for nil:NilClass
[root@localhost ~]# gem install rubygems-update -v 2.3.0
Fetching: rubygems-update-2.3.0.gem (100%)
Successfully installed rubygems-update-2.3.0
Parsing documentation for rubygems-update-2.3.0
Installing ri documentation for rubygems-update-2.3.0
1 gem installed //安装成功
[root@localhost yum.repos.d]# gem update --system
...
......
.........
RubyGems system software updated //升级成功
[root@localhost ~]# gem sources -a http://mirrors.aliyun.com/rubygems/ //添加国内阿里云的源
http://mirrors.aliyun.com/rubygems/ added to sources
[root@localhost ~]# gem sources -l //查看yum源
*** CURRENT SOURCES ***
https://rubygems.org/ //国外原始源
http://mirrors.aliyun.com/rubygems/ //新增的阿里源
[root@localhost ~]# gem sources --remove https://rubygems.org/ //移除国外原始源
https://rubygems.org/ removed from sources
[root@localhost ~]# gem sources -l
*** CURRENT SOURCES ***
http://mirrors.aliyun.com/rubygems/
[root@localhost ~]# gem install fpm //安装FPM工具
三:编译Nginx
[root@localhost ~]# rz -E //导入nginx包
[root@localhost ~]# ls
anaconda-ks.cfg nginx-1.15.9.tar.gz nginx.sh 公共 视频 文档 音乐
initial-setup-ks.cfg original-ks.cfg 模板 图片 下载 桌面
[root@localhost ~]# tar xf nginx-1.15.9.tar.gz -C /usr/src
[root@localhost ~]# cd /usr/src/nginx-1.15.9/
[root@localhost nginx-1.15.9]# yum -y install pcre-devel zlib-devel make rpm-build
[root@localhost nginx-1.15.9]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module && make && make install
四:打包Nginx生成RPM包
此处做shell脚本的主要原因是为了让用户下载完nginx包时系统自动完成nginx服务的启动从而提高用户体验
[root@localhost nginx-1.15.9]# cd
[root@localhost ~]# vim nginx.sh
#!/bin/bash useradd -M -s /sbin/nologin nginx //创建用户
ln -s /usr/local/nginx/sbin/nginx /sbin/ //做软连接
echo "www.source.com" > /usr/local/nginx/html/index.html //修改主页
nginx //启动nginx服务
[root@localhost ~]# fpm -s dir -t rpm -n nginx -v 1.15.9 -d 'pcre-devel,zlib-devel' -f --post-install /root/nginx.sh /usr/local/nginx
Created package {:path=>"nginx-1.15.9-1.x86_64.rpm"}
-s 表示对一个目录进行打包
-t 表示要打包成的类型
-n 表示软件包的名字
-v 表示要打包成的版本
-d 表示要指定的依赖包
-f 表示要指定的文件
/usr/local/nginx 表示指定的位置
[root@localhost ~]# rm -rf /usr/local/nginx/
[root@localhost ~]# rm -rf /usr/src/nginx-1.15.9/
[root@localhost ~]# rm -rf /usr/src/nginx-1.16.0/
[root@localhost ~]# rm -rf /usr/local/sbin/nginx
[root@localhost ~]# killall -9 nginx
[root@localhost ~]# userdel -r nginx
userdel:未找到 nginx 的主目录“/home/nginx”
[root@localhost ~]# ls
anaconda-ks.cfg nginx-1.15.9.tar.gz original-ks.cfg 视频 下载
initial-setup-ks.cfg nginx-1.16.0.tar.gz 公共 图片 音乐
nginx-1.15.9-1.x86_64.rpm nginx.sh 模板 文档 桌面
[root@localhost ~]# rpm -ivh nginx-1.15.9-1.x86_64.rpm
准备中... ################################# [100%]
正在升级/安装...
1:nginx-1.15.9-1 ################################# [100%]
[root@localhost ~]#
基于FPM制作RPM软件包!的更多相关文章
- Linux基于FPM制作RPM包(以Nginx为例)
1.搭建Epel Yum源 安装在线yum源 [root@localhost ~]# rpm -ivh epel-release-latest-.noarch.rpm //安装扩展源 [root@ ...
- 利用fpm制作rpm包
使用fpm制作rpm包 安装如下 [root@web01 ~]# yum install -y gcc zlib zlib-devel wget http://ruby.taobao.org/mirr ...
- fpm制作rpm包
一.前言 在企业中我们有事安装软件包.部分都是源码安装,如nginx安装路径都已经固化了,但实际业务中,我们都是把软件包安装到固定目录下,不满足需要,这是其一.其二,编译安装很耗时,比如mysql,特 ...
- fpm 制作rpm包
使用fpm命令制作rpm包并安装 工作中有如下情况需要将文件打包rpm: 避免重复工作,将源码程序打包为rpm 使用yum发布项目,项目打包为rpm 将自己写好的程序打包为rpm,提供给用户下载 其他 ...
- 基于FPM制作nginx RPM包
目录 环境 配置 FPM安装 环境 系统 其它 CentOS 7.5 需提前配置好epel 配置 [root@localhost ~]# yum clean all && yum ma ...
- fpm 制作 rpm 包
支持的 源类型包 ① dir : 将目录打包成所需要的类型, 可用于源码编译安装软件包 ② rpm : 对 rpm 包进行转换 ③ gem : 对 rubygem 包进行转换 ④ python : 将 ...
- linux制作RPM包
制作rpm包 1.制作流程1.1 前期工作 1)创建打包用的目录rpmbuild/{BUILD,SPECS,RPMS, SOURCES,SRPMS} 建议使用普通用户,在用户家目录中创建 2)确定好制 ...
- 制作RPM包
RPM包制作过程 1.1 前期工作 1)创建打包用的目录rpmbuild/{BUILD,SPECS,RPMS, SOURCES,SRPMS} 建议使用普通用户,在用户家目录中创建 2)确定好制作的对象 ...
- FPM制作Nginx的RPM软件包
FPM制作Nginx的rpm软件包 FPM相关参数-s:指定源类型-t:指定目标类型,即想要制作为什么包-n:指定包的名字-v:指定包的版本号-C:指定打包的相对路径-d:指定依赖于哪些包-f:第二次 ...
随机推荐
- Python代码混淆和加密技术
Python进行商业开发时, 需要有一定的安全意识, 为了不被轻易的逆向. 混淆和加密就有所必要了. 为了增加代码阅读的难度, 源代码的混淆非常必要, 一个在线的Python代码混淆网站. http: ...
- mongo的常用命令--转载
转载liyonghui的博文,出处 http://www.cnblogs.com/liyonghui/p/mongodb.html 博主写的特别好,对于我这个新手帮了大忙了,还将mongo和mysq ...
- Gym-TORCS安装
系统为Ubuntu16.04来安装Gym-TORCS 安装pip: sudo apt-get install python-pip sudo pip install --upgrade pip 安装p ...
- 快递查询API
https://market.aliyun.com/products/56928004/cmapi014394.html#sku=yuncode839400000
- Drawer 侧边栏、以及侧边栏内 容布局
一.Flutter Drawer 侧边栏 在 Scaffold 组件里面传入 drawer 参数可以定义左侧边栏,传入 endDrawer 可以定义右侧边栏.侧边栏默认是隐藏的,我们可以通过手指滑动显 ...
- 510,position的值,relative和absolute定位原点是
(absolute:生成绝对定位的元素) position属性用来规定元素的定位类型和方式 ①position:static 默认值,没有定位,元素出现在正常的流中: ②position:fixed ...
- 删除文件时提示,你需来自SYSTEM的权限
1. 提示如下 2. 对要删除的文件操作如下 2.1 为删除的文件添加本地账户 2.2 提示如下,多点几次继续就好 2.3 给本地账户添加完全控制权限
- Codeforces Round #577 (Div. 2) 题解
比赛链接:https://codeforc.es/contest/1201 A. Important Exam 题意:有\(n\)个人,每个人给出\(m\)个答案,每个答案都有一个分值\(a_i\), ...
- liux 命令行
查找文件 () find / -name httpd.conf #在根目录下查找文件httpd.conf,表示在整个硬盘查找 () find /etc -name httpd.conf #在/etc目 ...
- django urls.py 中的name 使用方法
使用场景: 当我们在url的时候,一般情况下都是使用很明确的url地址.如在网页里面使用<a href="/login">登录</a>.像这样的链接有很 多 ...