(1)安装src格式的rpm包html
源码格式的rpm包(一般是src格式)没法直接使用,须要加工制做后才能使用java
[root@localhost ~]# cd /yum/package/nginx
[root@localhost package]# lsweb
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 apache
# 这个包安装了之后会生成如下文件 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 bash
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 dom
warning: nginx-1.7.10-1.el6.ngx.src.rpm: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY 1:nginx ########################################### [100%]
(2)rpmbuild目录介绍ide
[root@localhost ~]# lsui
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服务以检验网页: