FPM Packaging Tools
FPM's author is Jordansissel.
FPM's GITHUB:HTTPS://GITHUB.COM/JORDANSISSEL/FPM
The FPM function is simply to convert one type of package into another type.
1. Supported source-type packages
Dir packages the directory into the required type, which can be used for source code compilation and installation of the package rpm for RPM conversion gem to convert the Rubygem package Python to package the Python module into the appropriate type
2. Supported Target type Packages
RPM Conversion to RPM package Deb conversion to Deb package Solaris conversion to Solaris package puppet to puppet module
3. FPM Installation
-y install ruby RubyGems ruby-devel Second step: Change Warehouse -A http://mirrors.aliyun.com/rubygems/ http://rubygems.org/ 1.8. 3 1.3. 3
4. FPM Parameters
For detailed use see FPM–HELP
Common parameters
-s specifies the source type -t specifies the target type, that is, the package that you want to make -n Specifies the name of the package-v Specifies the version number of the package -C Specifies the relative path of the package change directory to here before searching forfiles-D Specifies which packages are dependent on-F The second time the package is in the directory if there is an installation package with the same name, then overwrite it -p output of the directory of the installation package, do not want to put in the current directory you need to specify the--post-install package after the installation of the script to run With--after-install--pre-install package to run the script before the installation is complete;--before-install--post-uninstall The script to run after the package uninstallation is complete, and the script to run before the uninstall of the--after-remove--pre-uninstall package is completed; with--before-remove
Use instance – the actual combat custom Nginx RPM package 1. Compile and install Nginx
1 # Install dependent packages 2Yum-y Install Pcre-devel openssl-devel3 #创建虚拟用户4Useradd www-m-s/sbin/Nologin5 #下载Nginx包6Wget-p/server/tools/http://nginx.org/download/nginx-1.10.2.tar.gz7#解压文件8cd/server/tools/9Tar zxf nginx-1.10.2. tar.gzTen #编译安装Nginx OneCD nginx-1.10.2 A./configure--prefix=/application/nginx-1.10.2--user=www--group=www--with-http_ssl_module--with-Http_stub_status_module -Make &&Make Install - creating a soft connection theLn-s/application/nginx-1.10.2//application/nginx
2. Scripting
[[email protected] ~]# cd/server/scripts/[rootfpm scripts]# vim nginx_rpm.sh # This is the script to execute when the RPM package is installed # !/bin/-m-s/sbin/-s/application/nginx-1.10. 2//application/nginx
3. Packaging
[Email protected]~]# fpm-s dir-t rpm-n nginx-v1.10.2-D'Pcre-devel,openssl-devel'--post-install/server/scripts/nginx_rpm.sh-f/application/nginx-1.10.2/No value forEpoch is Set, defaulting to nil {:level=>: Warn}no value forEpoch is Set, defaulting to nil {:level=>: Warn} Created Package {:p ath="nginx-1.10.2-1.x86_64.rpm"} #查看打好的包 [[email protected]~]# ll-h nginx-1.10.2-1. x86_64.rpm-rw-r--r--1Root root8.7MNov1 -: Genevanginx-1.10.2-1. x86_64.rpm
4. Install the RPM package
Two ways to install RPM packages:
#此方式安装需要先安装Nginx依赖包
[Email protected] ~]# rpm-ivh nginx-1.10. 2-1. x86_64.rpmerror:Failed dependencies: pcreis needed by nginx-1.10 . 2-1. x86_64 OpenSSLis needed by nginx-1.10. 2-1. x86_64 But it will be reported as a dependency error, you need to install a dependency on Yum before installing the RPM package.
Yum install-y pcre-devel Openssl-devel
- Yum command to install RPM packages
Yum-y localinstall nginx-1.10. 2-1. x86_64.rpm This command automatically installs the RPM package dependencies before installing the RPM package.
Localinstall is calling the local installation package, more parameters man Yum
Caution 1. Relative path problems
# relative path [[email protected] nginx]# FPM-S dir-t rpm-n nginx-v1.10.2. No value forEpoch is Set, defaulting to nil {:level=>: Warn}no value forEpoch is Set, defaulting to nil {:level=>: Warn} Created Package {:p ath="nginx-1.10.2-1.x86_64.rpm"}[[email protected] nginx]# rpm-QPL nginx-1.10.2-1. x86_64.rpm/client_body_temp/conf/extra/Dynamic_pools/conf/extra/Static_pools ....... # Absolute Path [[Email protected]~]# fpm-s dir-t rpm-n nginx-v1.10.2/application/nginx-1.10.2/No value forEpoch is Set, defaulting to nil {:level=>: Warn}no value forEpoch is Set, defaulting to nil {:level=>: Warn} Created Package {:p ath="nginx-1.10.2-1.x86_64.rpm"}[[email protected]~]# RPM-QPL nginx-1.10.2-1. x86_64.rpm/application/nginx-1.10.2/client_body_temp/application/nginx-1.10.2/conf/extra/Dynamic_pools/application/nginx-1.10.2/conf/extra/Static_pools/application/nginx-1.10.2/conf/fastcgi.conf/application/nginx-1.10.2/conf/fastcgi.conf.default....... using RPM The-QPL command allows you to view the contents of the RPM package. Note: FPM is similar to tar packaging, except that FPM-punched packets can be identified by the Yum command.
2. Soft link Issues
[Email protected] ~]# fpm-s dir-t rpm-n nginx-v1.10.2/application/nginxno Value forEpoch is Set, defaulting to nil {:level=>: Warn} File already exists, refusing toContinue: nginx-1.10.2-1. x86_64.rpm {:level=>: Fatal} # error is because the current directory has the same name of the RPM package, you can use -The f parameter enforces overrides. [[Email protected]~]# fpm-s dir-t rpm-n nginx-v1.10.2-f/application/nginxno Value forEpoch is Set, defaulting to nil {:level=>: Warn} Force flag given. Overwriting Package at Nginx-1.10.2-1. x86_64.rpm {:level=>: Warn}no value forEpoch is Set, defaulting to nil {:level=>: Warn} Created Package {:p ath="nginx-1.10.2-1.x86_64.rpm"The package appears to be successful, but viewing the contents of the package is just a soft link file. [[Email protected]~]# RPM-QPL nginx-1.10.2-1. x86_64.rpm/application/Nginx Cause: The end of the directory /problem, similar to RM delete Soft link directory
Customized LNMP RPM Package ideas
Compile and install the nginx,mysql,php, there is a problem here, is that most of PHP relies on the environment is installed through Yum, but there is a libiconv-1.14.tar.gz package needs to compile the installation, installation has been specified in the installation directory, just packaged together.
Another problem is that the MySQL directory is larger and it takes a long time to pack with FPM. Usually we may need to optimize nginx or PHP, so that we have to repackage. So we can separate MySQL and pack them separately. Just add MySQL dependencies when making nginx+php rpm packages.
# PHP Package Reference Command First step: Create a script : /server/scripts/php_rpm.sh #!/bin/bash -s/application/php-5.5. +//application/php Step two: Make FPM pack 5.5'zlib-devel,libxml2-devel, Libjpeg-devel,libmcrypt-devel,libjpeg-turbo-devel,freetype-devel,libpng-devel,gd-devel,libcurl-devel, Libxslt-devel,mhash,mcrypt' --post-install/server/scripts/php_rpm.sh-f/usr/local/libiconv// application/php-5.5. /
Customized RPM packages for Linux systems