httpd2.4.27rpm Bag Making

Source: Internet
Author: User
Tags builtin rpmbuild

http2.4.27 RPM Package Production
1. Installing Rpm-build
Yum-y Install Rpm-build
2. Create a spec rule file with a normal user
Su-lxh
Vim Httpd.spec

Name:httpd
version:2.4.27
Release:1%{?dist}
Summary:compiled from 2.4.27 by Lxh

Group:system environment/daemons
License:gpl
Url:http://www.lxh.com
Source0:httpd-2.4.27.tar.gz
Source1:httpd
Source2:httpd.init
buildroot:% (Mktemp-ud%{_tmppath}/%{name}-%{version}-%{release}-xxxxxx)

BUILDREQUIRES:GCC, gcc-c++, Openssl-devel, make

%description
Apache Web server. Compiled from 2.4.27 by Lxh

%prep
%setup-q


%build
./configure--prefix=/usr/local/apache \
--bindir=/usr/sbin \
--WITH-APR=/USR/LOCAL/APR \
--with-apr-util=/usr/local/apr-util \
--with-expat=builtin \
--with-pcre=builtin \
--ENABLE-SSL \
--enable-modules=all
Make%{?_smp_mflags}


%install

%make_install


%clean
RM-RF%{buildroot}


%files
/usr/sbin/ab
/usr/sbin/apxs
/usr/sbin/dbmmanage
/usr/sbin/htdbm
/usr/sbin/htdigest
/usr/sbin/htpasswd
/usr/sbin/httxt2dbm
/usr/sbin/logresolve
%defattr (-,root,root,-)
/usr/local/apache/bin/*
/usr/local/apache/build/*
/usr/local/apache/cgi-bin/*
%config/usr/local/apache/conf/*
/usr/local/apache/error/*
/usr/local/apache/htdocs/*
/usr/local/apache/icons/*
/usr/local/apache/include/*
%dir/usr/local/apache/logs
%doc/usr/local/apache/man/*
%doc/usr/local/apache/manual/*
/usr/local/apache/modules/*
%post
Cp/usr/local/apache/bin/apachectl/etc/init.d/httpd
Sed-i ' 1a # chkconfig:2345 '/etc/init.d/httpd
Sed-i ' 2a # description:apache Web server '/etc/init.d/httpd
Chkconfig--add httpd
%preun
/ETC/INIT.D/HTTPD stop
Chkconfig--del httpd

%changelog
*tue Mar lxh<[email protected]> 2.4.27
--

Generate working Directory
Rpmbuild Httpd.spec

Drwxr-xr-x 3 lxh lxh 4096 August 1 15:24 BUILD
Drwxr-xr-x 2 lxh lxh 4096 August 1 15:26 buildroot
Drwxr-xr-x 3 lxh lxh 4096 August 1 14:18 RPMS
Drwxr-xr-x 2 lxh lxh 4096 August 1 14:01 SOURCES
Drwxr-xr-x 2 lxh lxh 4096 August 1 15:22 SPECS
Drwxr-xr-x 2 lxh lxh 4096 August 1 14:18 SRPMS
##############################################
2.1 Defining the RPM package information

RPM package information, which mainly defines what the user displays when they query the RPM package information. It contains the function description of RPM package, software version, copyright information and software authorization type and so on.

Detailed information is as follows:

Name defines the RPM package and must be filled in.

Version defines the revision number of the RPM package, and the recommendation is consistent with the name of the source package.

Release defines the version number of the RPM itself, using the default values.

Summary defines some introduction to the RPM package.

%description defines some descriptive information about the RPM package.

The group identifies the type of package to which it belongs.

License software licensing types, such as GPL, commercial, shareware.

The URL defines the home page of the software author.

The most important thing in RPM package information is the NVR, which is name, version, release. Because the name of the last generated RPM package is based on these three items.

The RPM name form, as follows: name-version-release.rpm.

2.2 Defining Source Packages

Source0 is used to define the source packages needed to make RPM packages. If you have multiple source packages when making RPM packages, use source and number blending, such as:

Source0:httpd-2.4.27.tar.gz
Source1:httpd
Source2:httpd.init

Attention:

Source0 must fill in, and fill in the name must be and download the source package name to be exactly the same, but also note that only tar.gz source package, in order to make RPM package.

2.3 Defining dependencies for RPM packages

RPM packages rely on the base library during the production process, and RPM packages sometimes require additional packages when they are installed. These can all be controlled by the following options.

Buildrequires defines the base library on which the RPM package is made. This option is optional.

Requires defines the package on which the RPM package is installed. This option is optional.

Attention:

A point to note here is that requires defines the packages on which it depends, in the case of Yum installations.

When we use Yum to install software A, Yum will check the RPM package after downloading a RPM package (the RPM package will give you the base library and software on which to install the RPM package).

If you check that the installation of a is dependent on software B, then Yum will automatically download and install B. b After the installation is complete, a will continue to be installed. If it is an intranet Yum source, we only need to put B in the intranet Yum source.

If you check that the installation of a does not require additional software support, Yum will automatically install a.

2.4 Compiling and installing the RPM package

This step is very important, similar to the installation of the source code./configure, make, make, install. Mainly include%build,%install and other options. As follows:

%build defining what to do when compiling a package

%install define the installation package and use the default values.

BuildRoot defines the virtual directory to use when installing or compiling, it is recommended that you use the default values. As follows:

% (MKTEMP-UD%{_TMPPATH}/%{NAME}-%{VERSION}-%{RELEASE}-XXXXXX)

This parameter is important because during the generation of the RPM package, the software is installed in the path above when the make install is executed. When packaging, you also rely on the virtual directory to operate on the root directory.

2.5 Files generated after installation

The RPM package creates the relevant directories and files when it is installed, which we can define here.

%files defines the relevant directories and files that are created when the RPM package is installed.

In this option%defattr (-,root,root) must be noted. It is a property of the specified installation file (Mode,owner,group), which is the default value, 0644 for the text file, and 0755 for the executable file.

2.6 Scripts that need to be executed before and after installation

%PREP Specifies the script that is executed before the RPM package is installed. We also do other things before we package the software. such as extracting tar.gz files. %prep is primarily used in conjunction with the%SETUP–Q command, it is recommended that you use the default values.

%POST Specifies the script that is executed after the RPM package is installed. After we have installed the RPM package, we can perform the operation of the software initialization by%post to achieve the goal. For example: Apache after installation, will apachectl copy into httpd and other operations. The default spec template file does not exist for this option.

%PREUN Specifies the script that is executed before the RPM package is unloaded, which is used primarily for software upgrades. The default spec template file does not exist for this option.

%postun Specifies the script that is executed after the RPM package is unloaded. The default spec template file does not exist for this option.

2.7 Software change Log

%changelog is primarily used for software change logs. This option is optional.

If you use the%changelog option, be sure to start with a * and--end. The time format is as follows:

* Day of the week and year XXX

--
##############################################
3. Source code Package production
The reason here is to decompress and re-archive the compression, because HTTPD relies on APR, specifying this process in. Spec is a hassle, so just do it right in the tar bag.
Cd/usr/local/src
Download apr-1.5.2.tar.gz apr-util-1.5.4.tar.gz httpd-2.4.27.tar.gz
TAR-ZXVF apr-1.5.2.tar.gz
TAR-ZXVF apr-util-1.5.4.tar.gz
TAR-ZXVF httpd-2.4.27.tar.gz

MV apr-1.5.2 HTTPD-2.4.27/SRCLIB/APR
MV apr-util-1.5.4 Httpd-2.4.27/srclib/apr-util

Tar cxvf httpd-2.4.27.tar.gz httpd-2.4.27/

MV Httpd-2.4.27.tar.gz/home/lxh/rpmbuild/sources/
MV Httpd-2.4.27/build/rpm/httpd.init/home/lxh/rpmbuild/sources/
Chown-r lxh:lxh/home/lxh/rpmbuild/sources/

Su-lxh
Vim/home/lxh/rpmbuild/sources/httpd
Httpd=/usr/local/apache/bin/httpd
Pidfile=/usr/local/apache/logs/httpd.pid
This is to provide the configuration of the startup script httpd, please according to your own situation, here I want to install httpd in/usr/loacl/apache/so do
cd/home/lxh/
CP Httpd.spec rpmbuild/specs/
Rpmbuild-ba Rpmbuild/specs/httpd.spec
4. Testing
Su-root
Cd/home/lxh/rpmbuild/rpms/x86_64
RPM-IVH httpd-2.2.27-1.el6.x86_64.rpm
[Email protected] x86_64]# RPM-IVH httpd-2.4.27-1.el6.x86_64.rpm
Preparing ... ########################################### [100%]
1:HTTPD ########################################### [100%]
Service httpd Start Normal
Complete!
5. Exception handling If present
[Email protected] x86_64]# RPM-IVH httpd-2.4.27-1.el6.x86_64.rpm
error:failed dependencies:
libexpat.so.0 () (64bit) is needed by httpd-2.4.27-1.el6.x86_64
Libpcre.so.1 () (64bit) is needed by httpd-2.4.27-1.el6.x86_64
You need to install the appropriate dependency package:
glibc-2.17-105.el7.x86_64.rpm
glibc-common-2.17-105.el7.x86_64.rpm
glibc-devel-2.17-105.el7.x86_64.rpm
glibc-headers-2.17-105.el7.x86_64.rpm
glibc-static-2.17-105.el7.x86_64.rpm
glibc-utils-2.17-105.el7.x86_64.rpm
pcre-8.32-15.el7.x86_64.rpm
pcre-devel-8.32-15.el7.x86_64.rpm

RPM-IVH glibc-*--force--nodeps
RPM-IVH pcre-*--force--nodeps

httpd2.4.27rpm Bag Making

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.