rpm包制作

1.安装fpm
yum -y install ruby rubygems ruby-devel rpm-build
gem install fpm

2.编译nginx并创建虚拟目录
mkdir -pv /opt/nginx/{etc/rc.d/init.d,sysconfig}

nginx-1.6.2.tar.gz放在/opt/nginx目录下

进入/opt/nginx目录下

tar -zxvf nginx-1.6.2.tar.gz

cd nginx-1.6.2

./configure --prefix=/usr/local/nginx --pid-path=/usr/local/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_dav_module --with-http_flv_module --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-debug --http-client-body-temp-path=/usr/local/nginx/client --http-proxy-temp-path=/usr/local/nginx/proxy --http-fastcgi-temp-path=/usr/local/nginx/fastcgi --http-uwsgi-temp-path=/usr/local/nginx/uwsgi --http-scgi-temp-path=/usr/local/nginx/scgi

make
make install DESTDIR=/opt/nginx

这里我把已经更改过的nginx配置存放到了里面,以及nginx的启动脚本放到了/opt/nginx/etc/rc.d/init.d/下面,两个shell脚本一个是在安装完成后创建nginx运行用户,和卸载rpm包之后执行的操作

3.在/opt/nginx目录下创建 after_install.sh ,after_remove.sh

vim after_install.sh
#!/bin/bash
source /etc/rc.d/init.d/functions
groupadd -r nginx
useradd -r -g nginx nginx
exit $?

vim after_remove.sh
#!/bin/bash
source /etc/rc.d/init.d/functions
rm -rf /usr/local/nginx
rm -rf /etc/nginx
userdel nginx
exit $?

4.打包命令

fpm -f -s dir 
-t rpm \
-n qding-nginx --epoch 0 -v1.6.2 --iteration 1.el6 \
-C /opt/nginx/ \
-p /root/ \
-d 'openssl-devel' -d 'gcc' -d 'gcc-c++' -d 'pcre-devel' -d 'zlib-devel' \
--verbose \
--category 'Development/Languages' \
--description 'nginx applications' \
--url 'nginx.org' \
--license 'BSD' \
-m 'bianji' \
--no-rpm-sign \
--after-install /opt/nginx/after_install.sh  \
--after-remove after_remove.sh \
--workdir /opt/nginx/ etc usr

5.FPM参数详解
Usage: fpm [options]

-p, --package PACKAGEFILE 管理的软件包

-n, --name PACKAGENAME 定义生成的软件包的名字

-v, --version VERSION 定义生成的软件包的版本

–iteration ITERATION 为软件包设置 iteration值 (‘release’ for RPM).

–epoch EPOCH 为软件包设置 epoch值

-d, —depends DEPENDENCY 设置软件包的依赖关系

-C DIRECTORY 在搜索files前先进入该目录

-t PACKAGE_TYPE 设置目标包的类型

-s SOURCE_TYPE 设置需要转换的包类型
–after-remote 卸载后执行脚本
–after-install 安装后执行脚本

成功后在/root下
在这里插入图片描述

  • rpm默认安装时默认的根目录就是系统的’/’:
    • rpm手动指定安装时的根目录[ --prefix=/temp/roach]:
      [root@localhost ~]# rpm -ivh roach-1.0.1-57.el6.x86_64.rpm --prefix=/temp/roach

rpm的卸载
[指定卸载的软件时,省略最后的扩展名.rpm]
[root@localhost ~]# rpm -e roach-1.0.1-57.el6.x86_64

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值