源码编译Nginx的RPM包

源码编译Nginx的RPM包

把源码转换成RPM

rpm 不能定制

步骤一:安装rpm-build软件

1)安装rpm-build软件包

[root@web1 ~]# yum -y install rpm-build

2)生成rpmbuild目录结构

[root@web1 ~]# rpmbuild -ba nginx.spec //会报错,没有文件或目录

[root@web1 ~]# ls /root/rpmbuild //自动生成的目录结构

BUILD BUILDROOT RPMS SOURCES SPECS SRPMS

SOURCS: 源码包存放路径

SPECS: 配置文件存放路径

RPMS: 把源码包转换成RPM 包的存放路径

3)准备工作,将源码软件复制到SOURCES目录

[root@web1 ~]# cp nginx-1.12.2.tar.gz /root/rpmbuild/SOURCES/

(制作的过程: 先在本机上安装源码包)

4)创建并修改SPEC配置文件

[root@web1 ~]# vim /root/rpmbuild/SPECS/nginx.spec

Name:nginx #源码包软件名称!!!不能写错

Version:1.12.2 #源码包软件的版本号

Release: 10 #制作的RPM包版本号

Summary: Nginx is a web server software. #RPM软件的概述

License:GPL #软件的协议开源协议,不能乱写,讲究法律效应

URL: www.test.com #网址

Source0:nginx-1.12.2.tar.gz #源码包文件的全称!!!不能写错

#BuildRequires: #制作RPM时的依赖关系

#Requires: #安装RPM时的依赖关系

%description

nginx [engine x] is an HTTP and reverse proxy server. #软件的详细描述

—————————————————————————————

%post

useradd nginx #非必需操作:rpm安装后命令或脚本(创建账户)

%prep

%setup -q #自动解压源码包,并cd进入目录

%build

./configure –user=nginx –group=nginx –with-stream –with-http_ssl_module #指定需要安装哪些模块

make %{?_smp_mflags}

%install

make install DESTDIR=%{buildroot}

%files

%doc

/usr/local/nginx/* #对哪些文件与目录打包

__________________________________________________________________________________________________

步骤二:使用配置文件创建RPM包

1)安装依赖软件包

[root@web1 ~]# yum -y install gcc pcre-devel openssl-devel

2)rpmbuild创建RPM软件包

[root@web1 ~]# rpmbuild -ba /root/rpmbuild/SPECS/nginx.spec

[root@web1 ~]# ls /root/rpmbuild/RPMS/x86_64/nginx-1.12.2-10.x86_64.rpm //查看刚刚打包的RPM包

[root@web1 ~]# rpm -qpi RPMS/x86_64/nginx-1.12.2-10.x86_64.rpm //查看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.

[root@web1 ~]# rpm -qpl nginx-1.12.2-10.x86_64.rpm //查看RPM包有哪些文件或目录组成

/usr

/usr/local

/usr/local/nginx

/usr/local/nginx/conf

/usr/local/nginx/conf/fastcgi.conf

/usr/local/nginx/conf/fastcgi.conf.default

/usr/local/nginx/conf/fastcgi_params

/usr/local/nginx/conf/fastcgi_params.default

/usr/local/nginx/conf/koi-utf

/usr/local/nginx/conf/koi-win

/usr/local/nginx/conf/mime.types

/usr/local/nginx/conf/mime.types.default

/usr/local/nginx/conf/nginx.conf

/usr/local/nginx/conf/nginx.conf.default

/usr/local/nginx/conf/scgi_params

/usr/local/nginx/conf/scgi_params.default

/usr/local/nginx/conf/uwsgi_params

/usr/local/nginx/conf/uwsgi_params.default

/usr/local/nginx/conf/win-utf

/usr/local/nginx/html

/usr/local/nginx/html/50x.html

/usr/local/nginx/html/index.html

/usr/local/nginx/logs

/usr/local/nginx/sbin

/usr/local/nginx/sbin/nginx

步骤三:安装、卸载软件

[root@web1 ~]# rpm -ivh /root/rpmbuild/RPMS/x86_64/nginx-1.12.2-10.x86_64.rpm or

yum install /root/rpmbuild/RPMS/x86_64/nginx-1.12.2-10.x86_64.rpm

[root@web1 ~]# rpm -qa |grep nginx

[root@web1 ~]# /usr/local/nginx/sbin/nginx

[root@web1 ~]# curl http://127.0.0.1/

本文版权归 飞翔沫沫情 作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出 原文链接 如有问题, 可发送邮件咨询,转贴请注明出处:https://www.fxkjnj.com/157/

发表评论

登录后才能评论