RPM为Redhat Package Manager缩写,是一个为Redhat系列Linux生产软件包的小工厂。其产品是RPM包,包含一些归档文件和meta信息;这些meta信息用来 记录如何安装和删除这些文件,一些帮助脚本,文件属性和描述行信息(如包依赖哪些包和被哪些包依赖)。整个RPM包的制作过程严格按照SPEC文件规范的 执行,然后通过rpmbuild命令来解析SPEC文件生成对应的RPM包。
至于为什么要制作rpm包,大家都明白,方便部署,比起源码来,这个部署速度更快
下面让以nginx为例,做rpm包制作:
1、安装需要的工具:
[root@salt-node1 ~]# yum -y install rpm-build rpmdevtools
2.下载nginx源码包
wget
3.生成spec文件
rpmdev-newspec -o nginx-1.6.3.spec Skeleton specfile (minimal) has been created to "nginx-1.6.3.spec".
4.编辑spec文件
> nginx-1.6.3.spec
Name: nginx-1.6.3
Version: 1.6.3
Release: 1%{?dist}
Summary: mall and high performance HTTP and reverse proxy server
Group: System Environment/stable
License: el6
URL: http://nginx.org
Source0: http://nginx.org/download/nginx-1.6.2.tar.gz
BuildRoot: %{_topdir}/BUILDROOT
BuildRequires: pcre-devel,zlib-devel,openssl,perl,perl(ExtUtils::Embed)
Requires: gcc,gcc-c++,make,pcre,openssl,perl-ExtUtils-Embed
%description
Nginx [engine x] is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3
proxy server written by Igor Sysoev.
%prep
%setup -q
%build
./configure
--user=nginx
--group=nginx
--prefix=/usr/local/src/nginx-1.6.3
--with-http_ssl_module
--with-http_realip_module
--with-http_addition_module
--with-http_sub_module
--with-http_dav_module
--with-http_flv_module
--with-http_gzip_static_module
--with-http_stub_status_module
--with-http_perl_module
--with-mail
--with-mail_ssl_module
#make %{?_smp_mflags}
make
%install
#rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
%clean
rm -rf $RPM_BUILD_ROOT
%post
chkconfig --add nginx
chkconfig --level 345 nginx on
echo "ulimit -SHn 51200" >> /etc/rc.local
%files
%defattr(-,root,root,-)
%doc
%changelog5.开始制作
[root@salt-node1 src]# rpmbuild -bb nginx-1.6.3.spec =======报错========= error: File /root/rpmbuild/SOURCES/nginx-1.6.3.tar.gz: No such file or directory =======解决========= [root@salt-node1 src]# mv nginx-1.6.3.tar.gz /root/rpmbuild/SOURCES/ =======重新执行===== [root@salt-node1 src]# rpmbuild -bb nginx-1.6.3.spec error: Failed build dependencies: pcre-devel is needed by nginx-1.6.3-1.6.3-1.el6.x86_64 zlib-devel is needed by nginx-1.6.3-1.6.3-1.el6.x86_64 ========解决======== [root@salt-node1 src]# yum -y install pcre-devel zlib-devel =======重新执行=====
本文出自 “Linux革命” 博客,请务必保留此出处http://kaibinyuan.blog.51cto.com/7304008/1636981
原文地址:http://kaibinyuan.blog.51cto.com/7304008/1636981