fpm介绍:
FPM功能简单说就是将一种类型的包转换成另一种类型。
FPM的github:https://github.com/jordansissel/fpm
fpm常用参数:
-s 指定源类型 -t 指定目标类型,即想要制作为什么包 -n 指定包的名字 -v 指定包的版本号 -C 指定打包的相对路径 Change directory to here before searching forfiles -d 指定依赖于哪些包 -f 第二次打包时目录下如果有同名安装包存在,则覆盖它 -p 输出的安装包的目录,不想放在当前目录下就需要指定 --post-install 软件包安装完成之后所要运行的脚本;同--after-install --pre-install 软件包安装完成之前所要运行的脚本;同--before-install --post-uninstall 软件包卸载完成之后所要运行的脚本;同--after-remove --pre-uninstall 软件包卸载完成之前所要运行的脚本;同--before-remove
安装fpm工具
yum -y install ruby rubygems ruby-devel [root@m01 ~]# gem sources --add https://gems.ruby-china.org/ --remove http://rubygems.org/ https://gems.ruby-china.org/ added to sources http://rubygems.org/ removed from sources [root@m01 ~]# gem install json -v 1.8.3 [root@m01 ~]# gem install fpm -v 1.3.3
安装nginx
useradd www -M -s /sbin/nologin tar xf nginx-1.6.2.tar.gz cd nginx-1.6.2 ./configure --prefix=/application/nginx-1.6.2 --user=www --group=www --with-http_ssl_module --with-http_stub_status_module make && make install ln -s /application/nginx-1.6.2/ /application/nginx 编写nginx安装后执行的脚本: [root@m01 application]# cat /server/scripts/nginx_rpm.sh #!/bin/bash useradd www -M -s /sbin/nologin ln -s /application/nginx-1.6.2/ /application/nginx
制作nginx的rpm包
[root@m01 application]# fpm -s dir -t rpm -n nginx -v 1.6.2 -d 'pcre-devel,openssl-devel' --post-install /server/scripts/nginx_rpm.sh -f /application/nginx-1.6.2/ no value for epoch is set, defaulting to nil {:level=>:warn} no value for epoch is set, defaulting to nil {:level=>:warn} Created package {:path=>"nginx-1.6.2-1.x86_64.rpm"}
客户端测试:
修改客户端的repo源
[root@oldboy nginx]# cd /etc/yum.repos.d/ [root@oldboy yum.repos.d]# ls oldboy.repo [root@oldboy yum.repos.d]# cat oldboy.repo [oldboy] name=Server baseurl=http://10.0.0.61 enable=1 gpgcheck=0
直接用yum本地安装nginx
[root@oldboy yum.repos.d]# yum install nginx 已加载插件:fastestmirror, security 设置安装进程 Loading mirror speeds from cached hostfile 解决依赖关系 --> 执行事务检查 ---> Package nginx.x86_64 0:1.6.2-1 will be 安装 --> 完成依赖关系计算 依赖关系解决 ================================================================================================== 软件包 架构 版本 仓库 大小 ================================================================================================== 正在安装: nginx x86_64 1.6.2-1 oldboy 2.2 M 事务概要 ================================================================================================== Install 1 Package(s) 总下载量:2.2 M Installed size: 5.0 M 确定吗?[y/N]:y 下载软件包: nginx-1.6.2-1.x86_64.rpm | 2.2 MB 00:00 运行 rpm_check_debug 执行事务测试 事务测试成功 执行事务 Warning: RPMDB altered outside of yum. ** Found 6 pre-existing rpmdb problem(s), 'yum check' output follows: nginx-mod-http-geoip-1.10.1-1.el6.x86_64 has missing requires of nginx nginx-mod-http-image-filter-1.10.1-1.el6.x86_64 has missing requires of nginx nginx-mod-http-perl-1.10.1-1.el6.x86_64 has missing requires of nginx nginx-mod-http-xslt-filter-1.10.1-1.el6.x86_64 has missing requires of nginx nginx-mod-mail-1.10.1-1.el6.x86_64 has missing requires of nginx nginx-mod-stream-1.10.1-1.el6.x86_64 has missing requires of nginx 正在安装 : nginx-1.6.2-1.x86_64 1/1 Verifying : nginx-1.6.2-1.x86_64 1/1 已安装: nginx.x86_64 0:1.6.2-1 完毕!
yum源的搭建见上一遍博文:
搭建本地yum源:
http://ronghuachen.blog.51cto.com/10543403/1863655