nginx打包rpm

安装rpmbuild,生成目录,编写spec文件

附上自己写的spec文件。

由于公司需要,nginx需要添加lua等依赖包,就自己通过编译过程打包了rpm。红色部分是根据编译的结果添加上去的

Name: nginx

Version: 1.2.7

Release: 1%{?dist}

Summary: A free,open-source,high-performance HTTP server and reverse proxy.

Group: System Enviroment/Daemons

License: BSD

URL: http://www.nginx.org

Source0: http://sysoev.ru/nginx/nginx-%{version}.tar.gz

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

BuildRequires: openssl-devel,lua-devel

Requires: openssl,lua

%description

nginx is a free, open-source, high-performance HTTP server and reverse proxy,

as well as an IMAP/POP3 proxy server. Nginx is known for its high

performance, stability, rich feature set, simple configuration, and low

resource consumption.

%prep

%setup -q

%build

export DESTDIR=%{buildroot}

./configure --user=www --group=www --prefix=/usr/local/nginx --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/run/nginx/nginx.lock --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_perl_module
--with-pcre=/root/rpmbuild/SOURCES/pcre-8.32 --with-debug --add-module=/root/rpmbuild/SOURCES/lua-nginx-module-0.9.1/ --add-module=/root/rpmbuild/SOURCES/ngx_devel_kit-0.2.19/ --add-module=/root/rpmbuild/SOURCES/echo-nginx-module-0.49/

make %{?_smp_mflags}

%pre

id www > /dev/null 2>&1

var1=`echo $?`

if [ $var1 != 0 ]; then

groupadd www > /dev/null 2>&1

useradd www -g www > /dev/null 2>&1

fi

mkdir -p /data/logs/nginx > /dev/null 2>&1

%install

make install DESTDIR=%{buildroot}

make -f /root/rpmbuild/BUILD/nginx-1.2.7/objs/Makefile install

cd /root/rpmbuild/BUILD/nginx-1.2.7/objs/src/http/modules/perl && make install

test -d "%{buildroot}/usr/local/nginx" || mkdir -p "%{buildroot}/usr/local/nginx"

test -d "%{buildroot}/usr/local/nginx/sbin" || mkdir -p "%{buildroot}/usr/local/nginx/sbin"

test ! -f "%{buildroot}/usr/local/nginx/sbin/nginx" || mv "%{buildroot}/usr/local/nginx/sbin/nginx" "%{buildroot}/usr/local/nginx/sbin/nginx.old"

cp /root/rpmbuild/BUILD/nginx-1.2.7/objs/nginx "%{buildroot}/usr/local/nginx/sbin/nginx"

test -d "%{buildroot}/usr/local/nginx/conf" || mkdir -p "%{buildroot}/usr/local/nginx/conf"

cp /root/rpmbuild/BUILD/nginx-1.2.7/conf/koi-win "%{buildroot}/usr/local/nginx/conf"

cp /root/rpmbuild/BUILD/nginx-1.2.7/conf/koi-utf "%{buildroot}/usr/local/nginx/conf"

cp /root/rpmbuild/BUILD/nginx-1.2.7/conf/win-utf "%{buildroot}/usr/local/nginx/conf"

test -f "%{buildroot}/usr/local/nginx/conf/mime.types" || cp /root/rpmbuild/BUILD/nginx-1.2.7/conf/mime.types "%{buildroot}/usr/local/nginx/conf"

cp /root/rpmbuild/BUILD/nginx-1.2.7/conf/mime.types "%{buildroot}/usr/local/nginx/conf/mime.types.default"

test -f "%{buildroot}/usr/local/nginx/conf/fastcgi_params" || cp /root/rpmbuild/BUILD/nginx-1.2.7/conf/fastcgi_params "%{buildroot}/usr/local/nginx/conf"

cp /root/rpmbuild/BUILD/nginx-1.2.7/conf/fastcgi_params "%{buildroot}/usr/local/nginx/conf/fastcgi_params.default"

test -f "%{buildroot}/usr/local/nginx/conf/fastcgi.conf" || cp /root/rpmbuild/BUILD/nginx-1.2.7/conf/fastcgi.conf "%{buildroot}/usr/local/nginx/conf"

cp /root/rpmbuild/BUILD/nginx-1.2.7/conf/fastcgi.conf "%{buildroot}/usr/local/nginx/conf/fastcgi.conf.default"

test -f "%{buildroot}/usr/local/nginx/conf/uwsgi_params" || cp /root/rpmbuild/BUILD/nginx-1.2.7/conf/uwsgi_params "%{buildroot}/usr/local/nginx/conf"

cp /root/rpmbuild/BUILD/nginx-1.2.7/conf/uwsgi_params "%{buildroot}/usr/local/nginx/conf/uwsgi_params.default"

test -f "%{buildroot}/usr/local/nginx/conf/scgi_params" || cp /root/rpmbuild/BUILD/nginx-1.2.7/conf/scgi_params "%{buildroot}/usr/local/nginx/conf"

cp /root/rpmbuild/BUILD/nginx-1.2.7/conf/scgi_params "%{buildroot}/usr/local/nginx/conf/scgi_params.default"

test -f "%{buildroot}/usr/local/nginx/conf/nginx.conf" || cp /root/rpmbuild/BUILD/nginx-1.2.7/conf/nginx.conf "%{buildroot}/usr/local/nginx/conf/nginx.conf"

cp /root/rpmbuild/BUILD/nginx-1.2.7/conf/nginx.conf "%{buildroot}/usr/local/nginx/conf/nginx.conf.default"

test -d "/var/run/nginx" || mkdir -p "/var/run/nginx"

test -d "%{buildroot}/usr/local/nginx/logs" || mkdir -p "%{buildroot}/usr/local/nginx/logs"

test -d "%{buildroot}/usr/local/nginx/html" || cp -R /root/rpmbuild/BUILD/nginx-1.2.7/html "%{buildroot}/usr/local/nginx"

test -d "%{buildroot}/usr/local/nginx/logs" || mkdir -p "%{buildroot}/usr/local/nginx/logs"

cp /root/rpmbuild/BUILD/nginx "%{buildroot}/usr/local/nginx/conf/nginx"

cp /root/rpmbuild/BUILD/nginx.conf "%{buildroot}/usr/local/nginx/conf/nginx.conf.pre"

cp /root/rpmbuild/BUILD/nginx_logrotate "%{buildroot}/usr/local/nginx/conf/nginx_logrotate"

该段由make install执行过程中得出

%post

cp /usr/local/nginx/conf/nginx /etc/rc.d/init.d/nginx > /dev/null 2>&1

cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak > /dev/null 2>&1

cp /usr/local/nginx/conf/nginx.conf.pre /usr/local/nginx/conf/nginx.conf > /dev/null 2>&1

cp /usr/local/nginx/conf/nginx_logrotate /etc/logrotate.d/nginx > /dev/null 2>&1

chmod a+x /etc/logrotate.d/nginx > /dev/null 2>&1

chmod a+x /etc/rc.d/init.d/nginx > /dev/null 2>&1

chkconfig --add nginx

chkconfig nginx on

/etc/init.d/nginx start

%preun

if ps aux | grep "nginx" | grep -v grep > /dev/null; then

pkill nginx > /dev/null

fi

chkconfig --del nginx

%postun

userdel www

rm -rf /etc/rc.d/init.d/nginx

rm -rf /etc/logrotate.d/nginx

%clean

rm -rf %{buildroot}

%files

/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/50x.html

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

/usr/local/nginx/sbin/nginx

/usr/lib64/perl5/perllocal.pod

/usr/local/lib64/perl5/auto/nginx/.packlist

/usr/local/lib64/perl5/auto/nginx/nginx.bs

/usr/local/lib64/perl5/auto/nginx/nginx.so

/usr/local/lib64/perl5/nginx.pm

/usr/local/nginx/sbin/nginx.old

/usr/local/share/man/man3/nginx.3pm

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

/usr/local/nginx/conf/nginx_logrotate

/usr/local/nginx/conf/nginx

#这些是执行rpmbuild -bb 之后提示缺少的文件添加在此处

%defattr(-,root,root,-)

%doc

%dir /usr/local/nginx/logs

%dir /var/run/nginx

%changelog

时间: 2024-10-11 22:08:16

nginx打包rpm的相关文章

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

RPM是RedHat Package Manager(RedHat软件包管理工具)的缩写,是一种用于互联网下载包的打包及安装工具,它包含在某些Linux分发版中.它生成具有.RPM扩展名的文件.使用rpm安装软件和管理软件非常的方便. 1.安装rpm-build [[email protected] ~]# yum -y install rpm-build redhat-rpm-config 2.建立目录结构 [[email protected] ~]# mkdir -p ~/rpmbuild/

FPM打包工具制作线上nginx的RPM包

一.安装FPM打包工具 1.FPM是ruby的模块,先安装FPM依赖的包 [[email protected] ~]#  yum -y install ruby rubygems ruby-devel rpm-build 2.因国内网络环境,访问http://rubygems.org/站点时不稳定,所以增加国内toabao提供的一个镜像站点,把原来的站点移除 [[email protected] ~]#  gem sources -a https://ruby.taobao.org/ [[ema

nginx打包成rpm

Name:    nginx        Version:    1.7.3    Release:    12%{?dist}Summary:    A free,open-source,high-performance HTTP server Group:    System Environment/DaemonsLicense:    BSD    URL:        http://rolin.com/Source0:    http://aa.com/nginx/%{name}-%

使用rpm-build制作nginx的rpm包

一.RPM包的分类 RPM有五种基本的操作功能:安装.卸载.升级.查询和验证. linux软件包分为两大类: (1)二进制类包,包括rpm安装包(一般分为i386和x86等几种) (2)源码类包,源码包和开发包应该归位此类(.src.rpm). 有时候为了方便源码包的安装,和我们自己订制软件包的需求,我们会把一些源码包按照我们的需求来做成rpm包,当有了源码包就可以直接编译得到二进制安装包和其他任意包.spec file是制作rpm包最核心的部分,rpm包的制作就是根据spec file来实现的

nginx的rpm包制作

nginx prm包 详细制作流程 1.准备工作 1.1:我这里准备了一台centos7的虚拟主机 1.2:官网下载最新的稳定版nginx源码包,地址:http://nginx.org/nginx-1.10.2.tar.gz 1.3:官网下载nginx的控制脚本,地址:https://www.nginx.com/resources/wiki/start/topics/examples/redhatnginxinit/ 1.4:手动安装一遍,看看都需要哪些依赖,所需依赖:gcc-c++,pcre-

制作nginx的RPM包

RPM为Redhat Package Manager缩写,是一个为Redhat系列Linux生产软件包的小工厂.其产品是RPM包,包含一些归档文件和meta信息;这些meta信息用来 记录如何安装和删除这些文件,一些帮助脚本,文件属性和描述行信息(如包依赖哪些包和被哪些包依赖).整个RPM包的制作过程严格按照SPEC文件规范的 执行,然后通过rpmbuild命令来解析SPEC文件生成对应的RPM包. 至于为什么要制作rpm包,大家都明白,方便部署,比起源码来,这个部署速度更快 下面让以nginx

RPM快速打包

回顾下安装软件的三种方式: 1.编译安装软件,优点是可以定制化安装目录.按需开启功能等,缺点是需要查找并实验出适合的编译参数,诸如MySQL之类的软件编译耗时过长. 2.yum安装软件,优点是全自动化安装,不需要为依赖问题发愁了,缺点是自主性太差,软件的功能.存放位置都已经固定好了,不易变更. ===>如果你现在还为是使用编译安装软件还是使用yum安装软件发愁,那你就out了. 3.编译源码,根据自己的需求做成定制RPM包-->搭建内网yum仓库--yum安装.结合前两者的优点,暂未发现什么缺

FPM制作nginx rpm包

fpm介绍: FPM功能简单说就是将一种类型的包转换成另一种类型. FPM的github:https://github.com/jordansissel/fpm fpm常用参数: -s          指定源类型 -t          指定目标类型,即想要制作为什么包 -n          指定包的名字 -v          指定包的版本号 -C          指定打包的相对路径  Change directory to here before searching forfiles

定制RPM包及yum仓库搭建(以安装nginx为例)

一.前提条件 #下面通过虚拟机准备了一台服务端,一台客户端,基于外网IP测试,以安装nginx为例. #两台机器公共配置 [[email protected] ~]# cat /etc/redhat-release CentOS release 6.7 (Final) [[email protected] ~]# uname -m x86_64 [[email protected] ~]# uname -r 2.6.32-573.el6.x86_64 #服务端配置 [[email protect