zoukankan      html  css  js  c++  java
  • FPM制作Nginx的RPM软件包

     FPM制作Nginx的rpm软件包

    FPM相关参数
    -s:指定源类型
    -t:指定目标类型,即想要制作为什么包
    -n:指定包的名字
    -v:指定包的版本号
    -C:指定打包的相对路径
    -d:指定依赖于哪些包
    -f:第二次包时目录下如果有同名安装包存在,则覆盖它
    -p:制作的rpm安装包存放路径,不想放在当前目录下就需要指定;
    –post-install:软件包安装完成之后所要运行的脚本;同–offer-install
    –pre-install:软件包安装完成之前所要运行的脚本;同–before-install
    –post-uninstall:软件包卸载完成之后所要运行的脚本;同–offer-remove
    –pre-uninstall:软件包卸载完成之前所要运行的脚本;同—before-remove
    –prefix:制作好的rpm包默认安装路径

    -------------------------------------------------------------------------------

    一、搭建epel源

    -------------------------------------------------------------------------------

    [root@localhost yum.repos.d]# rz                            #上传163镜像源在线yum
    [root@localhost yum.repos.d]# ls
    a  CentOS7-Base-163.repo

    [root@localhost yum.repos.d]# rz                            #上传epel源

    [root@localhost yum.repos.d]# ls

    a

    epel-release-latest-7.noarch.rpm 

    CentOS7-Base-163.repo                  

    [root@localhost yum.repos.d]# rpm -ivh epel-release-latest-7.noarch.rpm            #安装epel源  

    [root@localhost yum.repos.d]# ls 

    CentOS7-Base-163.repo     

    epel-release-latest-7.noarch.rpm 

    epel-testing.repo
     epel.repo

    [root@localhost yum.repos.d]# yum -y clean all              #清除缓存
    [root@localhost yum.repos.d]# yum makecache             #重建yum缓存

    Cannot retrieve metalink for repository: epel/x86_64. Please verify its path and try again 报错
    [root@localhost yum.repos.d]# vim epel.repo                     #修改epel文件
    将所有baseurl 开启
    将所有 metalink 注释掉

    [root@localhost yum.repos.d]# yum -y clean all              #再次清除缓存
    [root@localhost yum.repos.d]# yum makecache            #再次重建缓存成功

    --------------------------------------------------------------------------

    二、安装ruby环境和gem命令FPM

    --------------------------------------------------------------------------

    [root@localhost yum.repos.d]# yum   -y   install   ruby  rubygems  ruby-devel
    [root@localhost ~]#  gem update --system                             #升级rubygems版本
    Updating rubygems-update
    Fetching: rubygems-update-3.0.6.gem (100%)
    ERROR:  Error installing rubygems-update:
     rubygems-update requires Ruby version >= 2.3.0.
    ERROR:  While executing gem ... (NoMethodError)
        undefined method `version' for nil:NilClass
    #升级失败提示我们升级到2.3.0版本
    [root@localhost ~]#  gem install rubygems-update  -v  2.3.0       #升级到2.3.0版本
    Updating rubygems-update
    Fetching: rubygems-update-3.0.6.gem (100%)
    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 ~]#  gem update --system                     #在升级rubygems版本
    RubyGems system software updated
    --------------------------------------------------------------------------------------------
    [root@localhost ~]# gem sources -a http://mirrors.aliyun.com/rubygems/          #添加国内源
    source http://mirrors.aliyun.com/rubygems/ already present in the cache
    [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软件
    Installing ri documentation for fpm-1.11.0
    14 gems installed
    ---------------------------------------------------------------
    [root@localhost ~]# 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                     #将自己想要添加的内容写入到Nginx的网页
    nginx
    -----------------------------------------------------------
    [root@localhost ~]# fpm -s dir -t rpm -n nginx -v 1.10.2 -d 'pcre-devel,zlib-devel' -f  --post-install /root/nginx.sh /usr/local/nginx              #生成rpm包
    Need executable 'rpmbuild' to convert dir to rpm {:level=>:error}               #出现这个报错,需要安装rpm-build的安装包
    [root@localhost ~]# yum -y install rpm-build  #安装
    #生成rpm包
    [root@localhost ~]# fpm -s dir -t rpm -n nginx -v 1.10.2 -d 'pcre-devel,zlib-devel' -f  --post-install /root/nginx.sh /usr/local/nginx
    Created package {:path=>"nginx-1.10.2-1.x86_64.rpm"}
    [root@localhost ~]# ls
    =  anaconda-ks.cfg  nginx-1.10.2-1.x86_64.rpm  nginx.sh
    进行安装测试之前如果你之前安装过nginx的话需要将之前的Nginx删除干净
    [root@localhost ~]# rm -rf /usr/local/nginx
    [root@localhost ~]# rm -rf /usr/src/nginx
    [root@localhost ~]# rm -rf /usr/local/bin/nginx                #做过软连接的话需要删除软连接
    [root@localhost ~]#killall -9 nginx                                    #杀死Nginx进程
    [root@localhost ~]#  userdel -r nginx                                 #删除Nginx的测试用户
    [root@localhost ~]# rpm -ivh nginx-1.10.2-1.x86_64.rpm                       #安装Nginx进行测试
    Preparing...                          ################################# [100%]
    Updating / installing...
       1:nginx-1.10.2-1                   ################################# [100%]
    warning: %post(nginx-1.10.2-1.x86_64) scriptlet failed, exit status 1
    成功
  • 相关阅读:
    测试开发CICD——Docker—— docker info ——显示 Docker 系统信息,包括镜像和容器数
    测试开发CICD——Docker—— docker version ——显示 Docker 版本信息
    测试开发CICD——Docker—— 容器简单使用
    测试开发CICD——Docker—— 镜像简单使用
    Codeforces Round #430 (Div. 2)
    rvm 安装ruby报错
    BZOJ 2038: [2009国家集训队]小Z的袜子(hose)(莫队算法)
    codeforce round#511
    遥远的国度(换根+树剖)
    如何挖掘网络资源
  • 原文地址:https://www.cnblogs.com/ZCQ123456/p/11554930.html
Copyright © 2011-2022 走看看