Learn how to make an RPM installation package by customizing the Nginx RPM package

Source: Internet
Author: User

RPM is an abbreviation for the Redhat Package Manager (Redhat Packages management tool) and is a packaging and installation tool for the Internet download package, which is included in some Linux distributions. It generates a. RPM file extension. Using RPM to install software and manage software is very convenient.

1. Installing Rpm-build

[Email protected] ~]# yum-y install Rpm-build redhat-rpm-config

2. Create a directory structure

[Email protected] ~]# mkdir-p ~/rpmbuild/{build,rpms,sources,specs,srpms}[[email protected] ~]# tree-n ~/rpmbuild// Root/rpmbuild/├──build Storage Source Code ├──rpms storage for the RPM production process to manage the spec file ├──sources extracted files stored here ├──specs stored by R Pmbuild prepared binary Package └──srpms storage Rpmbuild made good source bundle 5 directories, 0 files

3. Download the source package

[Email protected] ~]# wget-p ~/rpmbuild/sources/http://nginx.org/download/nginx-1.4.7.tar.gz

4. Creating a. spec file

[[email protected] ~]# cd  ~/rpmbuild/specs[[email protected] specs]#  Vim nginx.specsname: nginxversion: 1.4.7release: 1%{?dist}summary: nginx rmp  package productiongroup: applications/archivinglicense: gplv2url: http:// www.nginx.orgSource: http://nginx.org/download/nginx-1.4.7.tar.gzBuildRoot: % (mktemp -ud % {_tmppath}/%{name}-%{version}-%{release}-xxxxxx) Buildrequires: gccrequires: openssl,openssl-devel, pcre-devel,pcre%descriptioncustom nginx rpm package%preprm -rf  $RPM _build_dir/ nginx-1.4.7tar fx  $RPM _source_dir/nginx-1.4.7.tar.gz%buildcd nginx-1.4.7./configure -- prefix=/home/application/nginx --with-http_ssl_module --with-http_stub_status_module -- with-http_gzip_static_modulemake %{?_smp_mflags}%installrm -rf %{buildroot}cd  Nginx-1.4.7make install destdir=%{buildroot}%cleAnrm -rf %{buildroot}%files%defattr (-,root,root,-)/home/application/nginx 

5.spec file explanation

#: Starting with # is a comment, and RPM ignores it. summary:    Simple description software. name :     defines the name of the RPM. version:    defining the software version release:    release version license:    defining the license group:      Software Classification source:    source url:       Source related website distribution:   Release Series packager:  Packager information%description: Detailed description of the software, can be multi-line%prep : processing prior to software compilation, such as decompression. %BUILD&NBSP: Start compiling software such as make%install : Start installing software, such as make install%files : Specifies which files need to be packaged, such as/usr/local/nginx% PREUN&NBSP: Defines the actions before unloading, such as killing processes. Here are only a few of the commonly used tags, in more detail please refer to: http://www.rpm.org/max-rpm/ch-rpm-inside.html 

6. Start RPM production

[Email protected] specs]# RPMBUILD-BB Nginx.spec

6. Test RPM Package

[[email protected] specs]# yum -y install /root/rpmbuild/rpms/x86_64/ nginx-1.4.7-1.el6.x86_64.rpmloaded plugins: fastestmirrorsetting up install  Processexamining /root/rpmbuild/rpms/x86_64/nginx-1.4.7-1.el6.x86_64.rpm: nginx-1.4.7-1.el6.x86_ 64marking /root/rpmbuild/rpms/x86_64/nginx-1.4.7-1.el6.x86_64.rpm to be installedloading  mirror speeds from cached hostfile * base: mirrors.btte.net *  epel: ftp.riken.jp * extras: mirrors.btte.net * updates:  Mirrors.btte.netresolving dependencies--> running transaction check---> Package  nginx.x86_64 0:1.4.7-1.el6 will be installed--> finished dependency  resolutiondependencies resolved==================================================================== ============================================================================================================================================== package                                        arch                                           Version                                             Repository                                                          size================================== =============================================================================================================== =================================================================installing: nginx                                          x86_64                                         1.4.7-1.el6                                         /nginx-1.4.7-1.el6.x86_64                                         732 ktransaction summary========== =============================================================================================================== =========================================================================================install        1 package (s) total size: 732 kinstalled size: 732  kdownloading packages:running rpm_check_debugrunning transaction testtransaction  test succeededrunning transaction  installing : nginx-1.4.7-1.el6.x86_64                                                                                                                                                                                 1/1   verifying  : nginx-1.4.7-1.el6.x86_64                                                                                                                                                                       &Nbsp;        1/1installed:  nginx.x86_64 0:1.4.7-1.el6                                                                                                                                                                                               complete!

At this point, the Nginx RPM package was completed and successfully installed ... You can extrapolate to make other software rpm packages.

This article is from the "Destiny." blog, be sure to keep this provenance http://hypocritical.blog.51cto.com/3388028/1694545

Learn how to make an RPM installation package by customizing the Nginx RPM package

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.