centos 下rpm包制作 (简单的nginx例子)

RPM包制作

1、安装环境

yum install rpm-build  redhat-rpm-config

useradd rbuild  #创建普通用户

su - rbuild  # 在普通用户下制作rpm

2、创建 制作rpm包目录

mkdir rpmbuild

cd rpmbuild

mkdir -pv {BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}

下载nginx包

wget http://nginx.org/download/nginx-1.10.3.tar.gz

mv nginx-1.10.3.tar.gz  SOURCES/    #移入此目录下

3、制作spec文件(创建rpm配置)

vim SPECS/nginx.spec

Name: nginx
Version: 1.10
Release:        3%{?dast}
Summary: myown nginx rpm

Group:  Applications/Archiving
License: GPLv2
URL:    http://www.nginx.org
Source0: http://nginx.org/download/nginx-1.10.3.tar.gz

BuildRoot: /home/rbuild/nginx
BuildRequires:  gcc
Requires:       openssl,openssl-devel,pcre-devel,pcre

%description
nginx rpm make


%prep
tar -zxf $RPM_SOURCE_DIR/nginx-1.10.3.tar.gz


%build
cd nginx-1.10.3
./configure \
--prefix=/usr/local/nginx \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_gzip_static_module

make %{?_smp_mflags}


%install
cd nginx-1.10.3

make install DESTDIR=%{buildroot}

%files
%defattr(-,root,root,-)
%config(noreplace) /usr/local/nginx/conf/*
/usr/local/nginx/html/
/usr/local/nginx/sbin/nginx


%changelog

  

4、制作rpm

rpmbuild -bb nginx.spec

没有报错即制作完成,在RPMS目录下

 

5、安装rpm

切换到root用户

rpm -ivh  rpm:PATH

 

6、检查效果

 

注:此次为简单测试安装,复杂rpm制作需研究spec文件配置

 

参考网址:

http://hypocritical.blog.51cto.com/3388028/1694545

https://zoco.me/post/centos-7-compile-nginx-and-build-into-rpm-package   #查看nginx官方spec配置

 

posted @ 2017-11-15 17:52  迷航xin  阅读(616)  评论(0编辑  收藏  举报