linux安装nginx rpm包,通过定制nginx的rpm包学习如何制作rpm安装包

RPM是RedHat Package Manager(RedHat软件包管理工具)的缩写,是一种用于互联网下载包的打包及安装工具,它包含在某些Linux分发版中。它生成具有.RPM扩展名的文件。使用rpm安装软件和管理软件非常的方便。

1.安装rpm-build[root@YunWei-136 ~]# yum -y install rpm-build redhat-rpm-config

2.建立目录结构[root@YunWei-136 ~]# mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}

[root@YunWei-136 ~]# tree -n ~/rpmbuild/

/root/rpmbuild/

├── BUILD        存放源代码

├── RPMS         存放用于管理rpm制作进程的spec文件

├── SOURCES      解压后的文件存放在这里

├── SPECS        存放由rpmbuild制作好的二进制包

└── SRPMS        存放由rpmbuild制作好的源码包

5 directories, 0 files

3.下载源码包[root@YunWei-136 ~]# wget -P ~/rpmbuild/SOURCES/ http://nginx.org/download/nginx-1.4.7.tar.gz

4.制作.spec文件[root@YunWei-136 ~]# cd  ~/rpmbuild/SPECS

[root@YunWei-136 SPECS]# vim nginx.spec

Name: nginx

Version: 1.4.7

Release: 1%{?dist}

Summary: nginx rmp package production

Group: Applications/Archiving

License: GPLv2

URL: http://www.nginx.org

Source: http://nginx.org/download/nginx-1.4.7.tar.gz

BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)

BuildRequires: gcc

Requires: openssl,openssl-devel,pcre-devel,pcre

%description

Custom nginx rpm package

%prep

rm -rf $RPM_BUILD_DIR/nginx-1.4.7

tar fx $RPM_SOURCE_DIR/nginx-1.4.7.tar.gz

%build

cd nginx-1.4.7

./configure \

--prefix=/home/application/nginx \

--with-http_ssl_module \

--with-http_stub_status_module \

--with-http_gzip_static_module

make %{?_smp_mflags}

%install

rm -rf %{buildroot}

cd nginx-1.4.7

make install DESTDIR=%{buildroot}

%clean

rm -rf %{buildroot}

%files

%defattr(-,root,root,-)

/home/application/nginx

5.spec文件解释#:以#开头是注释,rpm会忽略它。

Summary:   简单描述软件。

Name :    定义rpm的名称。

Version:   定义软件版本

Release:   发行版本

License:   定义许可证

Group:    软件分类

Source:   ×××地址

URL:      源码相关网站

Distribution: 发行版系列

Packager: 打包人的信息

%description:软件详细描述,可多行

%prep :软件编译之前的处理,如解压。

%build :开始编译软件,如make

%install :开始安装软件,如make install

%files :指定哪些文件需要被打包,如/usr/local/nginx

%preun :定义卸载之前的动作,如杀掉进程。

这里只介绍了几个常用的tag,更详细的请参考:http://www.rpm.org/max-rpm/ch-rpm-inside.html

6.开始RPM制作[root@YunWei-136 SPECS]# rpmbuild -bb nginx.spec

6.测试RPM包[root@YunWei-136 SPECS]# yum -y install /root/rpmbuild/RPMS/x86_64/nginx-1.4.7-1.el6.x86_64.rpm

Loaded plugins: fastestmirror

Setting up Install Process

Examining /root/rpmbuild/RPMS/x86_64/nginx-1.4.7-1.el6.x86_64.rpm: nginx-1.4.7-1.el6.x86_64

Marking /root/rpmbuild/RPMS/x86_64/nginx-1.4.7-1.el6.x86_64.rpm to be installed

Loading mirror speeds from cached hostfile

* base: mirrors.btte.net

* epel: ftp.riken.jp

* extras: mirrors.btte.net

* updates: mirrors.btte.net

Resolving Dependencies

--> Running transaction check

---> Package nginx.x86_64 0:1.4.7-1.el6 will be installed

--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================================================================================================

Package                                     Arch                                         Version                                           Repository                                                       Size

==================================================================================================================================================================================================================

Installing:

nginx                                       x86_64                                       1.4.7-1.el6                                       /nginx-1.4.7-1.el6.x86_64                                       732 k

Transaction Summary

==================================================================================================================================================================================================================

Install       1 Package(s)

Total size: 732 k

Installed size: 732 k

Downloading Packages:

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

Installing : nginx-1.4.7-1.el6.x86_64                                                                                                                                                                       1/1

Verifying  : nginx-1.4.7-1.el6.x86_64                                                                                                                                                                       1/1

Installed:

nginx.x86_64 0:1.4.7-1.el6

Complete!

至此,nginx的RPM包制作完成,并成功安装......大家可以举一反三制作其他软件的RPM包。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Cenos 6.7 x86_64 yum安装 yum localinstal nginx-1.6.3-1.x86_64.rpm 定制安装过程 1: FPM 打工具安装 修改yum源: 备份 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup 安装阿里云yum源 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo 安装依赖 yum -y install ruby rubygems ruby-devel 添加阿里云的Rubygems 仓库 gem sources -a http://mirrors.aliyun.com/rubygems/ #移除原生Ruby仓库 gem sources --remove http://rubygems.org/ 指定安装版本 gem install fpm -v 1.3.3 wget http://nginx.org/download/nginx-1.9.7.tar.gz wget http://nginx.org/download/nginx-1.6.3.tar.gz mkdir -p /application/tools cd /application/tools/ find /var/cache/yum/ -name "*rpm" yum install pcre-devel openssl-devel find /var/cache/ -type f -name '*rpm' find /var/cache/ -type f -name '*rpm'|xargs cp -t /tmp/ cd /tmp tar zcf nginx_yum.tar.gz *.rpm sz nginx_yum.tar.gz cd /application/tools/ useradd nginx -M -s /sbin/nologin tar zxf nginx-1.6.3.tar.gz ./configure --prefix=/application/nginx-1.6.3 --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module make make install ln -s /application/nginx-1.6.3/ /application/nginx /application/nginx/sbin/nginx ss -lntup|grep nginx ps -ef|grep nginx|grep -v grep netstat -lntup|grep nginx|grep -v grep curl 127.0.0.1 mkdir -p /server/scripts cd /server/scripts/ fpm -s dir -t rpm -n nginx -v 1.6.3 -d 'pcre-devel,openssl-devel' --post-install /server/scripts/nginx_rpm.sh -f /application/nginx-1.6.3/ 检查 rpm -qpl nginx-1.6.3-1.x86_64.rpm [root@nginx tools]# rpm -qpl nginx-1.6.3-1.x86_64.rpm /application/nginx-1.6.3/client_body_temp /application/nginx-1.6.3/conf/fastcgi.conf /application/nginx-1.6.3/conf/fastcgi.conf.default /application/nginx-1.6.3/conf/fastcgi_params /application/nginx-1.6.3/conf/fastcgi_params.default /application/nginx-1.6.3/conf/koi-utf /application/nginx-1.6.3/conf/koi-win /application/nginx-1.6.3/conf/mime.types /application/nginx-1.6.3/conf/mime.types.default /a

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值