# - Dependencies
yum -y install gcc gcc-c++ make zlib-devel pcre-devel openssl-devel geoip-devel rpm-build
# - Creating user to perform this process, as the same is not recommended with root user:
useradd -m rpmbuilder
# - Download Packages
Source RPM
http://nginx.org/packages/centos/7/SRPMS/
*Obs = Version used in this lab was 1.14.0
Modulos
# - nginx-module-vts
git clone git://github.com/vozlt/nginx-module-vts.git
# - nginx-module-sts
git clone git://github.com/vozlt/nginx-module-sts.git
# - nginx-module-stream-sts
git clone git://github.com/vozlt/nginx-module-stream-sts.git
# - Install the downloaded package
rpm -Uvh nginx-versão_baixada.ngx.src.rpm
Move the rpmbuild generated and the modules downloaded in your home, to the home of the user who will execute the process, and then assign permission to it:
mv /root/rpmbuild /home/rpmbuilder/ && chown -R rpmbuilder. /home/rpmbuilder/rpmbuild
mv nginx-* /home/rpmbuilder/rpmbuild/SOURCES
Compact the modules
tar -czvf nginx-module-sts.tar.gz nginx-module-sts
tar -czvf nginx-module-stream-sts.tar.gz nginx-module-stream-sts
tar -czvf nginx-module-vts.tar.gz nginx-module-vts
Remove the folders from the modules and leave only the compressed files
rm -rf nginx-module-sts
rm -rf nginx-module-stream-sts
rm -rf nginx-module-vts
Access the SPECS directory and edit the nginx.spec file
vim nginx.spec
1 - Step
Add the modules in% define BASE_CONFIGURE_ARGS
--add-dynamic-module=nginx-module-vts \
--add-dynamic-module=nginx-module-sts \
--add-module=nginx-module-stream-sts
#-----------------------------------Complete declaration -------------------------------
%define BASE_CONFIGURE_ARGS $(echo "--prefix=%{_sysconfdir}/nginx \
--sbin-path=%{_sbindir}/nginx \
--modules-path=%{_libdir}/nginx/modules \
--conf-path=%{_sysconfdir}/nginx/nginx.conf \
--error-log-path=%{_localstatedir}/log/nginx/error.log \
--http-log-path=%{_localstatedir}/log/nginx/access.log \
--pid-path=%{_localstatedir}/run/nginx.pid \
--lock-path=%{_localstatedir}/run/nginx.lock \
--http-client-body-temp-path=%{_localstatedir}/cache/nginx/client_temp \
--http-proxy-temp-path=%{_localstatedir}/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=%{_localstatedir}/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=%{_localstatedir}/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=%{_localstatedir}/cache/nginx/scgi_temp \
--user=%{nginx_user} \
--group=%{nginx_group} \
--with-compat \
--with-file-aio \
--with-threads \
--with-http_addition_module \
--with-http_auth_request_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_mp4_module \
--with-http_random_index_module \
--with-http_realip_module \
--with-http_secure_link_module \
--with-http_slice_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_v2_module \
--with-mail \
--with-mail_ssl_module \
--with-stream \
--with-stream_realip_module \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--add-dynamic-module=nginx-module-vts \
--add-dynamic-module=nginx-module-sts \
--add-module=nginx-module-stream-sts")
2 - Step
Declare the modules to be compiled in Source
Source14: nginx-module-vts.tar.gz
Source15: nginx-module-sts.tar.gz
Source16: nginx-module-stream-sts.tar.gz
#-----------------------------------Complete declaration-------------------------------
Source0: http://nginx.org/download/%{name}-%{version}.tar.gz
Source1: logrotate
Source2: nginx.init.in
Source3: nginx.sysconf
Source4: nginx.conf
Source5: nginx.vh.default.conf
Source7: nginx-debug.sysconf
Source8: nginx.service
Source9: nginx.upgrade.sh
Source10: nginx.suse.logrotate
Source11: nginx-debug.service
Source12: COPYRIGHT
Source13: nginx.check-reload.sh
Source14: nginx-module-vts.tar.gz
Source15: nginx-module-sts.tar.gz
Source16: nginx-module-stream-sts.tar.gz
License: 2-clause BSD-like license
3 - Step
Add tar commands to unzip the modules as follows:
%prep
%setup -q
tar -xzf %SOURCE14
tar -xzf %SOURCE15
tar -xzf %SOURCE16
4 - Step
Enter the path to where the modules will be compiled
%files
%defattr(-,root,root)
#Modules
%{_libdir}/nginx/modules
5 - Step
Save the file and run rpmbuild
rpmbuild -ba ~/rpmbuild/SPECS/nginx.spec
Wait for the following result
Executando (%clean): /bin/sh -e /var/tmp/rpm-tmp.3LJguv
+ umask 022
+ cd /home/rpmbuilder/rpmbuild/BUILD
+ cd nginx-1.14.0
+ /usr/bin/rm -rf /home/rpmbuilder/rpmbuild/BUILDROOT/nginx-1.14.0-1.el7_4.ngx.x86_64
+ exit 0
6 - Step
Test
shell> rpm -ivh nginx-1.14.0-1.el7_4.ngx.x86_64.rpm
Preparando... ################################# [100%]
Updating / installing...
1:nginx-1:1.14.0-1.el7_4.ngx ################################# [100%]
----------------------------------------------------------------------
Thanks for using nginx!