nginx之RPM包制作教程
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx之RPM包制作教程相关的知识,希望对你有一定的参考价值。
1,需求
案例使用nginx-1.12.2版本的源码软件,生成对应的RPM包软件,具体要求如下:
软件名称为nginx
软件版本为1.12.2
RPM软件包可以查询描述信息
RPM软件包可以安装及卸载
2,安装rpm-build软件
1)安装rpm-build软件包
[[email protected] ~]# yum -y install rpm-build
2)生成rpmbuild目录结构
[[email protected] ~]# rpmbuild -ba nginx.spec //会报错,没有文件或目录
[[email protected] ~]# ls /root/rpmbuild //自动生成的目录结构
BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
3)准备工作,将源码软件复制到SOURCES目录
[[email protected] ~]# cp nginx-1.12.2.tar.gz /root/rpmbuild/SOURCES/
4)创建并修改SPEC配置文件
[[email protected] ~]# vim /root/rpmbuild/SPECS/nginx.spec
Name:nginx #软件名,不能乱写,必须与源码包名一样
Version:1.12.2 #源码版本号,不能乱写
Release: 10 #rpm修改了几次,顺便写
Summary: Nginx is a web server software. #软件描述
License:GPL #GPL协议顺便写,顺便发布
URL: www.test.com
Source0:nginx-1.12.2.tar.gz
#BuildRequires: #依赖包
#Requires: #依赖包
%description #软件描述详细信息
nginx [engine x] is an HTTP and reverse proxy server.
%post #安装后执行的脚本
useradd nginx //非必需操作:安装后脚本(创建账户)
%prep
%setup –q //自动解压源码包,并cd进入目录
%build
./configure
make %{?_smp_mflags}
%install
make install DESTDIR=%{buildroot}
cp /root/rpmbuild/SPECS/nginx.sh %{buildroot}/usr/local/nginx/
##注意,cp非必须操作,注意,这里是将一个脚本拷贝到安装目录,必须提前准备该文件
%files
%doc
/usr/local/nginx/* //对哪些文件与目录打包
%changelog
3,使用配置文件创建RPM包
1)安装依赖软件包
[[email protected] ~]# yum -y install gcc pcre-devel zlib-devel openssl-devel
2)rpmbuild创建RPM软件包
[[email protected] ~]# rpmbuild -ba /root/rpmbuild/SPECS/nginx.spec
[[email protected] ~]# ls /root/rpmbuild/RPMS/x86_64/nginx-1.12.2-10.x86_64.rpm
[[email protected] ~]# rpm -qpi RPMS/x86_64/nginx-1.12.2-10.x86_64.rpm
Name : nginx Relocations: (not relocatable)
Version : 1.12.2 Vendor: (none)
Release : 10 Build Date: Mon 02 May 2016 02:30:53 AM PDT
Install Date: (not installed) Build Host: localhost
Group : Applications/Internet Source RPM: nginx-1.8.0-1.src.rpm
Size : 721243 License: GPL
Signature : (none)
URL : www.nginx.org
Summary : Nginx is a web server software.
Description :
nginx [engine x] is an HTTP and reverse proxy server.
[[email protected] ~]# rpm -qpl nginx-1.12.2-10.x86_64.rpm
4,安装、卸载软件
[[email protected] ~]# rpm -ivh RPMS/x86_64/nginx-1.12.2-10.x86_64.rpm
[[email protected] ~]# rpm -qa |grep nginx
[[email protected] ~]# /usr/local/nginx/sbin/nginx
[[email protected] ~]# curl http://127.0.0.1/
以上是关于nginx之RPM包制作教程的主要内容,如果未能解决你的问题,请参考以下文章