温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

fpm定制nginx-rpm包

发布时间:2020-07-18 08:18:58 来源:网络 阅读:383 作者:mlwzby 栏目:建站服务器

实验环境介绍:

[root@nginx ~]# uname -r

2.6.32-573.el6.x86_64

[root@nginx ~]# cat /etc/redhat-release

CentOS release 6.7 (Final)


打包之前需要在测试机上先安装 nginx 服务

安装过程如下

[root@nginx ~]# useradd -s /sbin/nologin/ -M nginx

[root@nginx ~]# yum -y install pcre-devel openssl-devel

[root@nginx ~]# tar zxf nginx-1.6.2.tar.gz

[root@nginx ~]# cd nginx-1.6.2

[root@nginx ~]# ./configure \

--user=nginx \

--group=nginx \

--prefix=/application/nginx-1.6.2 \

--with-http_stub_status_module \

--with-http_ssl_module

[root@nginx nginx-1.6.2]# make && make install

[root@nginx nginx-1.6.2]# ln -s /application/nginx-1.6.2/ /application/nginx


fpm 制作开始

通过 yum 安装依赖包

[root@nginx ~]# yum -y install ruby rubygems ruby-devel


更换 yum 源

[root@nginx ~]# gem sources -a http://mirrors.aliyun.com/rubygems/

[root@nginx ~]# gem sources --remove http://rubygems.org/

[root@nginx ~]# gem sources --list

[root@nginx ~]# gem install fpm -v 1.3.3

-v 指定要安装的 fpm 版本,也可以不指定。直接执行 gem install fpm


写一个脚本,只需要写入添加的 nginx 用户和创建软连接的命令即可

[root@nginx ~]# vim nginx_fpm.sh

#!/bin/bash

useradd -s /sbin/nologin/ -M nginx

ln -s /application/nginx-1.6.2/ /application/nginx


执行打包命令

[root@nginx ~]# fpm -s dir -t rpm -n nginx -v 1.6.2 -d 'pcre-devel,openssl-devel' --post-install /root/nginx_fpm.sh -f /application/nginx-1.6.2/

-s:指定源类型

-t:执行目标类型

-n:执行包的名字

-v:指定包的版本号

-d:指定依赖于哪些包

--post-install:软件安装完要运行的脚本

-f:第二次包时目录下如果有同名安装包存在,则覆盖它


在一台新机器上测试一下刚才的 rpm 包

使用 yum -y localinstall 命令可以自行解决安装问题

[root@lvs1 ~]# yum -y localinstall nginx-1.6.2-1.x86_64.rpm


启动 nginx 服务成功

[root@lvs1 ~]# /application/nginx/sbin/nginx

[root@lvs1 ~]# lsof -i :80

COMMAND  PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

nginx   1842  root    6u  IPv4  14884      0t0  TCP *:http (LISTEN)

nginx   1843 nginx    6u  IPv4  14884      0t0  TCP *:http (LISTEN)

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI