Prerequisites
- OS with Centos 7 installed.
- Enable "epel-release" repo
- Install below packages
- openssl openssl-devel gcc gd-devel GeoIP GeoIP-devel libgdata-devel.x86_64 libgdata.x86_64 gcc-c++ flex bison yajl yajl-devel curl-devel curl GeoIP-devel doxygen zlib-devel gcc make automake autoconf libtool pcre pcre-devel libxml2 libxml2-devel curl curl-devel httpd-devel rpm-build.x86_64 rpm-build-libs.x86_64 redhat-lsb-core.x86_64 mhash.x86_64 mhash-devel.x86_64 patch.x86_64 luajit.x86_64 libmodsecurity.x86_64 dkms gcc make kernel-devel bzip2 binutils patch libgomp glibc-headers glibc-devel kernel-headers libXrandr libmodsecurity-devel.x86_64 git mlocate
- Download and install nginx source RPM from nginx repo (http://nginx.org/packages/centos/7/SRPMS)
- Download third-party modules from github or nginx module page
- GitHub : https://github.com/
- Nginx : https://www.nginx.com/resources/wiki/modules/
Pleased third-party module in side the "/root/rpmbuild/SOURCES/modules"
- Modules we are going to include are as follow
- echo-nginx-module : https://github.com/openresty/echo-nginx-module
- lua-nginx-module : https://github.com/openresty/lua-nginx-module
- memc-nginx-module : https://github.com/openresty/memc-nginx-module
- nginx_cross_origin_module : https://github.com/yaoweibin/nginx_cross_origin_module
- nginx-goodies-nginx-sticky : https://github.com/Refinitiv/nginx-sticky-module-ng
- nginx-modsecurity-module : https://github.com/SpiderLabs/ModSecurity-nginx
- nginx-sticky-module
- nginx_upstream_check_module : https://github.com/yaoweibin/nginx_upstream_check_module
- ngx_devel_kit : https://github.com/vision5/ngx_devel_kit
- ngx_http_enhanced_memcached_module : https://github.com/bpaquet/ngx_http_enhanced_memcached_module
- ngx-http-secure-download : https://www.nginx.com/resources/wiki/modules/secure_download/
- redis2-nginx-module : https://github.com/openresty/redis2-nginx-module
- redis-nginx-module : https://github.com/onnimonni/redis-nginx-module
- set-misc-nginx-module : https://github.com/openresty/set-misc-nginx-module
- srcache-nginx-module : https://github.com/openresty/srcache-nginx-module
- We need to build modsecurity and LuaJit libiries separately and install on the server
- Modsecurity : https://github.com/SpiderLabs/ModSecurity
- LuaJIT: https://luajit.org/download/LuaJIT-2.0.5.tar.gz
Build ModSecurity
- Download ModSecurity from above URL
- Execute below commands to build it.
./build.sh
./configure
make
make install
Build LuaJIT
Download the LuaJIT from above URL. Then make the build and install.
makemake install
Build NGINX with Modules
In some modules, its has patches to apply for nginx source code before build. You can check whether patches are include or not for that module by go through the each module folder. If you fine any patch file you have to patch it.
Ex:
Apply Patches
To apply patch you have to first extract the nginx source tar file. It is in "/root/rpmbuild/SOURCES".
Then execute this command
patch -p0 < /root/rpmbuild/SOURCES/modules/nginx-goodies-nginx-sticky/patches/cookies.patch
You have to put full path when it prompt for File path. You find the path from locate command.
Once you applied all the patches, create a tar.gz file of nginx source code. Backup old one before do it.
Then include module you want to build with nginx to nginx.spec file.
Now it is time build the nginx.
To build the nginx execute this command.
To build the nginx execute this command.
rpmbuild -bb nginx.spec
It will take some time to build the final RPM base on the number of modules you have added.
If you successfully completed the build you will get some thing like this at the end.
If you successfully completed the build you will get some thing like this at the end.
Note: If you are a beginner, add module by module and build.
You can install the nginx now.
You can verify available modules by typing nginx -V command.




















No comments:
Post a Comment