fpm制作FPM软件包

大前提是nginx服务必须提前搭好

centOS版本要用7.6

安装epel源 (电脑必须能上网)

首先关闭防火墙

[root@localhost ~]# tar xf epel-release-latest-7.noarch.rpm

[root@localhost yum.repos.d]# ls
a CentOS-Media.repo epel-testing.repo
CentOS-Base.repo epel.repo local.repo

##yum路径下需要这四个repo文件

[root@localhost yum.repos.d]# yum clean all && yum makecache

[root@localhost yum.repos.d]# yum -y install ruby rubygems ruby-devel   rpm-build

[root@localhost ~]# gem install rubygems-update -v 2.3.0  ##更新最新版本,版本根据下一条命令的报错来安装

[root@localhost ~]# gem update --system    #升级rubygems版本

[root@localhost ~]# gem sources -l  #查看当前源

[root@localhost ~]# gem sources -a http://mirrors.aliyun.com/rubygems/       ##国内源添加

[root@localhost ~]# gem install fpm    ##安装fpm工具

[root@localhost ~]# yum source --remove https://rubygems.org/    ##

[root@localhost ~]# vi nginx.sh

#!/bin/bash
useradd -M -s /sbin/nologin nginx
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin
echo www.crushlinux.com > /usr/local/nginx/html/index.html
nginx

[root@localhost ~]# fpm -s dir -t rpm -n nginx -v 1.16.0 -d 'pcre-devel,zlib-devel,openssl-devel' -f --post-install /root/nginx.sh /usr/local/nginx

测试

rm -rf /usr/local/nginx
rm -rf /usr/src/nginx-1.16.0
userdel -r nginx
killall -9 nginx

tar xf nginx-1.16.0-1.x86_64.rpm -C /usr/src/

完成

猜你喜欢

转载自www.cnblogs.com/maoyanqing/p/11521894.html