加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

基于FPM制作RPM包

发布时间:2020-12-14 00:37:26 所属栏目:Linux 来源:网络整理
导读:1、搭建Epel? Yum源 安装在线yum源 [[email?protected] ~]# rpm -ivh epel-release-latest- 7 .noarch.rpm // 安装扩展源 [[email?protected] yum.repos.d]# lsa epel -release-latest- 7 .noarch.rpm epel-testing.repo Centos- 7 .repo epel.repo 或 ? [[e

1、搭建Epel? Yum源

安装在线yum源

[[email?protected] ~]# rpm -ivh epel-release-latest-7.noarch.rpm      //安装扩展源
[[email?protected] yum.repos.d]# ls
a  epel-release-latest-7.noarch.rpm  epel-testing.repo  Centos-7.repo  epel.repo

? [[email?protected] ~]# ls /etc/yum.repos.d/

? backup ?CentOS-Base.repo ?CentOS-Media.repo ?epel.repo ?epel-testing.repo

? ?

? [[email?protected] yum.repos.d]# yum clean all?&& yum makecache? //清除并新建yum缓存

2、安装ruby环境和gem命令(gem命令是从rubygem仓库安装软件,类似yum从yum仓库安装软件)

安装软件包,安装时要出现3个安装的软件
[[email?protected] yum.repos.d]# yum -y install ruby rubygems ruby-devel

[[email?protected] ~]# gem update --system      //升级rubygems版本
[[email?protected] ~]# gem install rubygems-update -v 2.3.0    //安装新版本
[[email?protected] ~]# gem update --system    //升级

[[email?protected] ~]# gem sources -a http://mirrors.aliyun.com/rubygems/  //添加国内源
[[email?protected] ~]# gem sources --remove https://rubygems.org/        //移除国外源
[[email?protected] ~]# gem sources -l     //查看当前源

[[email?protected] ~]# gem install fpm     //安装fpm工具

3、编译nginx,在保证nginx安装完的基础上打包,查看nginx的80端口

[[email?protected] ~]# netstat -anpt | grep :80    //查询nginx的接口

4、打包nginx包生成rpm包

脚本
[[email?protected] ~]# vim nginx.sh
#!/bin/bash

useradd -M -s /sbin/nologin nginx        //创建用户
ln -s /usr/local/nginx/sbin/nginx/ /sbin     //设置软连接
echo www.crushlinux.com > /usr/local/nginx/html/index.html   //在网页文件中写入测试内容
/usr/local/nginx/sbin/nginx         //开启nginx

打包时报错,修改

[[email?protected] ~]# fpm -s dir -t rpm -n nginx -v 1.16.1 -d pcre-devel,zlib-devel -f --post-install /root/nginx.sh /usr/local/nginx/
报错信息
Need executable rpmbuild to convert dir to rpm {:level=>:error}

修改
[[email?protected] ~]# yum list | grep build
[[email?protected] ~]# yum -y install rpm-build
[[email?protected] ~]# fpm -s dir -t rpm -n nginx -v 1.16.1 -d pcre-devel,zlib-devel -f --post-install /root/nginx.sh /usr/local/nginx/
打包成功,在当前目录下生成一个rpm包
Created package {:path=>"nginx-1.16.1-1.x86_64.rpm"}

5、安装自己制作的软件包,并查看端口

[[email?protected] ~]# rpm -ivh nginx-1.16.1-1.x86_64.rpm    //安装自己制作的包
[[email?protected] ~]# netstat -anpt | grep 80     //查看端口

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读