首页 > 代码库 > nginx打包rpm
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
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
nginx打包rpm
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。