linux 文件 格式 源码,27. 文件系统——编译安装源码格式的rpm包(src.rpm)

(1)安装src格式的rpm包

源码格式的rpm包(通常是src格式)无法直接使用,需要加工制作后才能使用

[root@localhost ~]# cd /yum/package/

[root@localhost package]# lsaxel-2.4                                 nginx-1.7.10-1.el6.ngx.src.rpm

# 现在想安装使用源码格式的nginx,但这个软件包不是二进制格式的,安装了以后无法正常使用

axel-2.4.tar.gz                          repodata

axis-1.2.1-7.5.el6_5.noarch.rpm          xen-4.4.1-5.el6.x86_64.rpm

axis-javadoc-1.2.1-7.5.el6_5.noarch.rpm  zsh-4.3.10-7.el6.x86_64.rpm

axis-manual-1.2.1-7.5.el6_5.noarch.rpm   zsh-html-4.3.10-7.el6.x86_64.rpm

[root@localhost package]# rpm -qpl nginx-1.7.10-1.el6.ngx.src.rpm# 这个包安装了以后会生成以下文件

warning: nginx-1.7.10-1.el6.ngx.src.rpm: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY

logrotate

nginx-1.7.10.tar.gz

# 这就是源码文件

nginx.conf

nginx.init

nginx.service

nginx.spec

# 制作rpm包所需要的spec文件

nginx.suse.init

nginx.suse.logrotate

nginx.sysconf

nginx.upgrade.sh

nginx.vh.default.conf

nginx.vh.example_ssl.conf

[root@localhost package]# rpm -ivh nginx-1.7.10-1.el6.ngx.src.rpmwarning: nginx-1.7.10-1.el6.ngx.src.rpm: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY

1:nginx                  warning: user builder does not exist - using root

warning: group builder does not exist - using root

# 提示用户不存在,需要创建该用户

...

warning: user builder does not exist - using root

warning: group builder does not exist - using root

[root@localhost package]# useradd builder

[root@localhost package]# rpm -ivh nginx-1.7.10-1.el6.ngx.src.rpmwarning: nginx-1.7.10-1.el6.ngx.src.rpm: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY

1:nginx                  ########################################### [100%]

(2)rpmbuild目录介绍

[root@localhost ~]# lsanaconda-ks.cfg  Documents  if_exist.sh  install.log.syslog  Music     Public    Templates

Desktop          Downloads  install.log  mkscript            Pictures  rpmbuild  Videos

# 安装到了rpmbuild目录下

[root@localhost ~]# cd rpmbuild/

[root@localhost rpmbuild]# lsSOURCES  SPECS

[root@localhost rpmbuild]# cd SOURCES/

[root@localhost SOURCES]# lslogrotate            nginx.init       nginx.suse.logrotate  nginx.vh.default.conf

nginx-1.7.10.tar.gz  nginx.service    nginx.sysconf         nginx.vh.example_ssl.conf

nginx.conf           nginx.suse.init  nginx.upgrade.sh

# 该目录用来存放所有制作rpm包所需要的源码、配置文件等

[root@localhost SOURCES]# cd ../SPECS/

[root@localhost SPECS]# lsnginx.spec

#此文件将被用来制作rpm包

[root@localhost SPECS]# rpmbuild -ba nginx.spec# -ba表示编译生成一个源码格式以及一个二进制格式的包,如果是-bb,表示只生成二进制格式

error: Failed build dependencies:

pcre-devel is needed by nginx-1.7.10-1.el6.ngx.x86_64

#报错表示需要很多依赖的包

(3)通过spec文件来制作rpm包

解决了依赖包的问题后,再次使用rpmbuild命令来制作rpm包:

[root@localhost SPECS]# rpmbuild -ba nginx.spec...

checking for socklen_t ... found

checking for in_addr_t ... found

...

Wrote: /root/rpmbuild/RPMS/x86_64/nginx-debuginfo-1.7.10-1.el6.ngx.x86_64.rpm

Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.uOpvTX

+ umask 022

+ cd /root/rpmbuild/BUILD

+ cd nginx-1.7.10

+ /bin/rm -rf /root/rpmbuild/BUILDROOT/nginx-1.7.10-1.el6.ngx.x86_64

+ exit 0

[root@localhost SPECS]# cd ..

[root@localhost rpmbuild]# lsBUILD  BUILDROOT  RPMS  SOURCES  SPECS  SRPMS

#多了几个目录,其中RPMS就是用来存放制作好的rpm包的

[root@localhost RPMS]# lsx86_64

[root@localhost RPMS]# cd x86_64/

[root@localhost x86_64]# lsnginx-1.7.10-1.el6.ngx.x86_64.rpm        nginx-debuginfo-1.7.10-1.el6.ngx.x86_64.rpm

nginx-debug-1.7.10-1.el6.ngx.x86_64.rpm

此时使用rpm -ivh命令安装即可

(4)安装使用rpm包

[root@localhost x86_64]# rpm -ivh nginx-1.7.10-1.el6.ngx.x86_64.rpmPreparing...                ########################################### [100%]

1:nginx                  ########################################### [100%]

----------------------------------------------------------------------

Thanks for using nginx!

Please find the official documentation for nginx here:

* http://nginx.org/en/docs/

Commercial subscriptions for nginx are available on:

* http://nginx.com/products/

# 安装成功

[root@localhost x86_64]# cd ../..

[root@localhost rpmbuild]# lsBUILD  BUILDROOT  RPMS  SOURCES  SPECS  SRPMS

[root@localhost rpmbuild]# cd SRPMS/

[root@localhost SRPMS]# lsnginx-1.7.10-1.el6.ngx.src.rpm

# SRPMS包中存放的是src格式的rpm包

nginx是个服务器,现在可以启动它:

[root@localhost x86_64]# apachectl stopAH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message

httpd (no pid file) not running

# 先关闭apache服务器

[root@localhost x86_64]# service nginx startStarting nginx:                                            [  OK  ]

启动成功,访问web服务以检验网页:

951c1e34552c99f03f95ac92540bbff4.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值