Use FPM tool to create an RPM package

Source: Internet
Author: User

Use FPM tool to create an RPM package

This rpm package is made using the fpm tool, and FPM is very easy to use. This command can make the installation and uninstallation of the rpm package more elegant. You can make some preparations before installation, after the installation, you can finish some work, and make some preparations before detaching the software. For example, you can check whether the corresponding service is stopped or not, you just need to define these as scripts, and you can easily implement them by specifying the corresponding options in fpm.

The parameters involved here are:
-- Pre-install FILE: indicates the script to be run before installation.
-- Post-install FILE: indicates the script to be run after installation.
-- Pre-uninstall FILE: indicates the script to be run before uninstalling
-- Post-uninstall FILE: indicates the script to be run after uninstallation.

1. Install the fpm Tool

# Yum-y install ruby rubygems ruby-devel rpm-build

# Gem sources-a http://ruby.taobao.org/

# Gem sources-r https://rubygems.org/

# Gem install fpm


2. Package luajit

# Mkdir/tmp/luajit

# Cd/usr/local/src

# Wget http://luajit.org/download/LuaJIT-2.0.4.tar.gz

# Tar xvzf LuaJIT-2.0.4.tar.gz

# Cd LuaJIT-2.0.4

# Make PREFIX =/usr

# Make install PREFIX =/usr DESTDIR =/tmp/luajit

# Fpm-s dir-t rpm-n LuaJIT-v 2.0.4 -- iteration 1. el7-C/tmp/luajit/-p/root -- description 'luajit rpm package' -- url 'HTTP: // luajit.org'

 

3. Pack tengine

# Mkdir/tmp/tengine

# Cd/usr/local/src

# Wget-O lua-nginx-module-0.9.16.tar.gz https://codeload.github.com/openresty/lua-nginx-module/tar.gz/v0.9.16

# Tar xvzf lua-nginx-module-0.9.16.tar.gz

# Wget http://tengine.taobao.org/download/tengine-2.1.0.tar.gz

# Tar xvzf tengine-2.1.0.tar.gz

# Cd tengine-2.1.0

 

#./Configure -- prefix =/opt/share/nginx \

-- Sbin-path =/opt/sbin/nginx \

-- Conf-path =/opt/etc/nginx. conf \

-- Error-log-path =/opt/log/nginx/error. log \

-- Http-log-path =/opt/log/nginx/access. log \

-- User = nginx \

-- Group = nginx \

-- Http-client-body-temp-path =/opt/lib/nginx/tmp/client_body \

-- Http-proxy-temp-path =/opt/lib/nginx/tmp/proxy \

-- Http-uwsgi-temp-path =/opt/lib/nginx/tmp/uwsgi \

-- Pid-path =/opt/run/nginx. pid \

-- Lock-path =/opt/lock/subsys/nginx \

With-http_ssl_module \

With-http_realip_module \

With-http_addition_module \

With-http_gzip_static_module \

With-http_gunzip_module \

With-http_secure_link_module \

With-http_stub_status_module \

With-http_sysguard_module \

-- With-file-aio \

-- Add-module = ../lua-nginx-module-0.9.16 \

-- With-cc-opt = '-g-O2-fstack-protector -- param = ssp-buffer-size = 4-Wformat-Werror = format-security '\

-- With-ld-opt = '-Wl,-Bsymbolic-functions-Wl,-z, relro'

 

# Make

# Make install DESTDIR =/tmp/tengine

 

# Cd/tmp/tengine/opt

# Mkdir-p lib/nginx/tmp/{client_body, proxy, uwsgi}

# Mkdir-p lock/subsys/nginx

 

# Cd/tmp/tengine

# Mkdir etc/rc. d/init. d

# Cp/etc/rc. d/init. d/nginx etc/rc. d/init. d

# Mkdir etc/logrotate. d

# Cp/etc/logrotate. d/nginx etc/logrotate. d

# Mkdir tmp

Script to be run before installation
# Vim tmp/install_before.sh

#! /Bin/bash

[[-N 'ps aux | grep ngin [x] '] & killall-9 nginx
[[-E/opt/etc/nginx] & cp-a/opt/etc/nginx // opt/etc/nginx _ $ (date + % F _ % H -% M-% S)

Script to be run after installation

# Vim tmp/install_after.sh

#! /Bin/bash

[[-N 'getent group nginx'] | groupadd-r nginx
[[-N 'getent passwd nginx'] | useradd nginx-r-g nginx-s/sbin/nologin

[[-N 'getent group www-data'] | groupadd-r www-data
[[-N 'getent passwd www-data'] | useradd www-data-r-g www-data-s/sbin/nologin

Mkdir-p/data/log/nginx

If [[-e/var/log/nginx]; then
If [[-L/var/log/nginx]; then
Rm-f/var/log/nginx & ln-s/data/log/nginx/var/log/nginx
Else
Mv/var/log/nginx/*/data/log/nginx/
Rm-rf/var/log/nginx & ln-s/data/log/nginx/var/log/nginx
Fi
Else
Ln-s/data/log/nginx/var/log/nginx
Fi

/Opt/sbin/nginx-c/opt/etc/nginx. conf

Pack tengine

# Chmod + x tmp/*. sh

# Fpm-s dir-t rpm-n tengine-v 2.1.0 -- iteration 1. waf. el7-C/tmp/tengine/-p/root -- description 'tengine rpm package' -- url 'HTTP: // tengine.taobao.org '-- pre-install/tmp/tengine/tmp/install_before.sh -- post-install/tmp/tengine/tmp/install_after.sh

View rpm software package information
# Rpm-qp -- scripts/root/tengine-2.1.0-1.waf.ele.el7.x86_64.rpm

Final Installation Steps

# Yum-y install pcre-devel openssl-devel

# Rpm-Uvh LuaJIT-2.0.4-1.el7.x86_64.rpm

# Rpm-Uvh tengine-2.1.0-1.waf.el7.x86_64.rpm

You may also like the following RPM articles:

Use FPM to quickly create an RPM package

Getting started with creating an RPM package

In Linux, how does one create an RPM package?

Create your own rpm package

Directory structure and configuration after rpm installation in Linux

Brief Introduction and demo of rpm and yum

RedHat Linux --- rpm command details

Use FPM to easily create an RPM package

This article permanently updates the link address:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.