(1)安装src格式的rpm包
源码格式的rpm包(通常是src格式)无法直接使用,需要加工制作后才能使用
[root@localhost ~]# cd /yum/package/
[root@localhost package]# ls
axel-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.rpm
warning: 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.rpm
warning: 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 ~]# ls
anaconda-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]# ls
SOURCES SPECS
[root@localhost rpmbuild]# cd SOURCES/
[root@localhost SOURCES]# ls
logrotate 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]# ls
nginx.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]# ls
BUILD BUILDROOT RPMS SOURCES SPECS SRPMS #多了几个目录,其中RPMS就是用来存放制作好的rpm包的
[root@localhost RPMS]# ls
x86_64
[root@localhost RPMS]# cd x86_64/
[root@localhost x86_64]# ls
nginx-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.rpm
Preparing... ########################################### [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]# ls
BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
[root@localhost rpmbuild]# cd SRPMS/
[root@localhost SRPMS]# ls
nginx-1.7.10-1.el6.ngx.src.rpm # SRPMS包中存放的是src格式的rpm包
nginx是个服务器,现在可以启动它:
[root@localhost x86_64]# apachectl stop
AH00558: 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 start
Starting nginx: [ OK ]
启动成功,访问web服务以检验网页:
本文出自 “重剑无锋 大巧不工” 博客,请务必保留此出处http://wuyelan.blog.51cto.com/6118147/1619949
27. 文件系统——编译安装源码格式的rpm包(src.rpm)
原文地址:http://wuyelan.blog.51cto.com/6118147/1619949