fpm 制作nginx rpm包
安装玩fpm后详细参数为:
-s #<==source,指定源类型-t #<==target,指定目标类型,即想要制作为什么包-n #<==name,指定包的名字-v #<==version,指定包的版本号-C #<==change,指定打包的相对路径-d #<==depend,指定依赖于哪些包-f #<==force,第二次打包时目录下如果有同名安装包存在,则覆盖它-p #<==输出的安装包的目录,不想放在当前目录下就需要指定--post-install #<==软件包安装完成之后所要运行的脚本;同--after-install--pre-install #<==软件包安装完成之前所要运行的脚本;同--before-install--post-uninstall #<==软件包卸载完成之后所要运行的脚本;同--after-remove--pre-uninstall #<==软件包卸载完成之前所要运行的脚本;同--before-remove1.定制nginx的rpm包
准备操作
mkdir /application/tools/ -p #<==统一软件包存放目录
sed -i 's#keepcache=0#keepcache=1#g' /etc/yum.conf #<==开启yum缓存
find /var/cache/ -type f -name '*rpm'|xargs rm -f
cd /application/tools/
wget -q http://nginx.org/download/nginx-1.6.3.tar.gz #<==下载nginx-1.6.3
编译安装nginx
[root@m01 tmp]# yum install pcre pcre-devel openssl openssl-devel -y#<==安装pcre库,openssl软件,因为等下编译安装时,需要安装ssl模块[root@m01 tmp]# rpm -qa openssl openssl-devel pcre pcre-devel#<==检查openssl-devel-1.0.1e-48.el6_8.1.x86_64pcre-7.8-7.el6.x86_64openssl-1.0.1e-48.el6_8.1.x86_64pcre-devel-7.8-7.el6.x86_64[root@m01 tools]# find /var/cache/ -type f -name '*rpm'|xargs cp -t /tmp/#<==另存rpm包,因为很多人的系统环境可能不一致,需要的rpm包可能不同。[root@m01 tools]# cd /tmp/ && tar zcf nginx_yum.tar.gz *.rpm#<==打包[root@m01 tmp]# cd /application/tools/#<==切换到软件包存放目录[root@m01 tools]# useradd nginx -M -s /sbin/nologin #<==添加nginx用户[root@m01 tools]# tar xf nginx-1.6.3.tar.gz #<==解包[root@m01 tools]# cd nginx-1.6.3#<==切换到nginx1.6.3目录下[root@m01 nginx-1.6.3]# ./configure --prefix=/application/nginx-1.6.3 --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module#<==配置过程内容省略,自行脑补……[root@m01 nginx-1.6.3]# echo $?#<==检查配置过程是否出错0[root@m01 nginx-1.6.3]# make && make install#<==编译&&配置过程内容省略,自行脑补……[root@m01 nginx-1.6.3]# echo $?#<==检查编译与配置过程是否出错0[root@m01 nginx-1.6.3]# ln -s /application/nginx-1.6.3/ /application/nginx#<==做软链接[root@m01 nginx-1.6.3]# ll -d /application/nginx-1.6.3/ /application/nginx#<==检查lrwxrwxrwx 1 root root 25 2016-07-29 17:37 /application/nginx -> /application/nginx-1.6.3/drwxr-xr-x 6 root root 4096 2016-07-29 17:37 /application/nginx-1.6.3/编写脚本
mkdir /server/scripts -pcd /server/scripts/cat >>nginx_rpm.sh<<EOF#!/bin/bashuseradd nginx -M -s /sbin/nologinln -s /application/nginx-1.6.3/ /application/nginxEOF打包
fpm -s dir -t rpm -n nginx -v 1.6.3 -d 'pcre,pcre-devel,openssl,openssl-devel' --post-install /server/scripts/nginx_rpm.sh -f /application/nginx-1.6.3/
安装遇到问题:

安装yum install -y rpm-build
如果里面有gcc make的错误解决方法:
yum install -y gcc
完成后



浙公网安备 33010602011771号