银河麒麟高级服务器v10 sp2 下fpm工具打包rpm

一、当前操作系统版本

 二、安装fpm

2.1 安装ruby及依赖

yum install ruby rubygems ruby-devel rpm-build

2.2 添加阿里云rubygems仓库

[root@server ~]# gem sources

*** CURRENT SOURCES ***

https://rubygems.org/

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

http://mirrors.aliyun.com/rubygems/ added to sources

[root@server ~]# gem sources

*** CURRENT SOURCES ***

https://rubygems.org/

http://mirrors.aliyun.com/rubygems/

2.3 移除原生的ruby的仓库

[root@server ~]# gem sources --remove https://rubygems.org/

https://rubygems.org/ removed from sources

[root@server ~]# gem sources

*** CURRENT SOURCES ***

http://mirrors.aliyun.com/rubygems

2.4 安装fpm 1.3.3版本

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

Fetching: ffi-1.15.5.gem (100%)

Building native extensions. This could take a while...

Successfully installed ffi-1.15.5

Fetching: childprocess-4.1.0.gem (100%)

Successfully installed childprocess-4.1.0

Fetching: clamp-0.6.5.gem (100%)

Successfully installed clamp-0.6.5

Fetching: cabin-0.9.0.gem (100%)

Successfully installed cabin-0.9.0

Fetching: arr-pm-0.0.11.gem (100%)

Successfully installed arr-pm-0.0.11

Fetching: backports-3.23.0.gem (100%)

Successfully installed backports-3.23.0

Fetching: json-2.6.2.gem (100%)

Building native extensions. This could take a while...

Successfully installed json-2.6.2

Fetching: fpm-1.3.3.gem (100%)

Successfully installed fpm-1.3.3

8 gems installed

三 、制作nginx的rpm包

 3.1 安装nginx依赖

yum install -y pcre-devel openssl-devel

3.2 下载上传nginx 1.22源码至服务器

3.3 源码编译nginx

./configure \

--prefix=/usr/local/nginx \

--sbin-path=/usr/sbin/nginx \

--conf-path=/usr/local/nginx/conf/nginx.conf \

--error-log-path=/var/log/nginx/error.log \

--http-log-path=/var/log/nginx/access.log \

--pid-path=/var/run/nginx/nginx.pid \

--lock-path=/var/lock/nginx.lock \

--user=nginx \

--group=nginx \

--with-http_ssl_module \

--with-http_flv_module \

--with-http_stub_status_module \

--with-http_gzip_static_module \

--http-client-body-temp-path=/var/tmp/nginx/client/ \

--http-proxy-temp-path=/var/tmp/nginx/proxy/ \

--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \

--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \

--http-scgi-temp-path=/var/tmp/nginx/scgi \

--with-pcre

make  && make DESTDIR=/opt/nginx install

3.4 制作nginx.service 并保存在/opt/nginx/usr/local/nginx/nginx.servic

[root@uplook system]# vim /usr/lib/systemd/system/nginx.service

[Unit]

Description=The nginx HTTP and reverse proxy server

After=network-online.target remote-fs.target nss-lookup.target

Wants=network-online.target

[Service]

Type=forking

PIDFile=/var/run/nginx/nginx.pid

# Nginx will fail to start if /run/nginx.pid already exists but has the wrong

# SELinux context. This might happen when running `nginx -t` from the cmdline.

# https://bugzilla.redhat.com/show_bug.cgi?id=1268621

ExecStartPre=/usr/bin/rm -f /var/run/nginx/nginx.pid

#ExecStartPre=/usr/sbin/nginx -t

ExecStartPre=/usr/bin/mkdir -p /var/tmp/nginx/

ExecStart=/usr/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

ExecReload=/usr/sbin/nginx -s reload

ExecStop=/usr/sbin/nginx -s quit

KillSignal=SIGQUIT

TimeoutStopSec=5

KillMode=process

PrivateTmp=true

[Install]

WantedBy=multi-user.target

3.5 生成rpm包 

fpm -s dir -t rpm -n nginx -v 1.22 -d 'pcre-devel,openssl-devel' --pre-install /tools/pre-nginx.sh --post-install /tools/post-nginx.sh -C /opt/nginx/ -f

附一:/tools/pre-nginx.sh

[root@server tools]# cat pre-nginx.sh

#!/bin/bash

useradd -M -s /sbin/nologin nginx

mkdir -p /var/tmp/nginx/client/

附二:/tools/post-nginx.sh

[root@server tools]# cat post-nginx.sh

#!/bin/bash

cp -f /usr/local/nginx/nginx.service /usr/lib/systemd/system/nginx.service

rm -rf /usr/local/nginx/nginx.service

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值