Recompile Nginx to add Nginx Push Stream Module

NginX is a very popular web server, and one of the most frequent need is add a new nginx module after installing it. This tutorial guides how to recompile nginx to add nginx push stream module on CentOS 6.

First, we need to find out which is current nginx build configuration:

[bash][root@intranet nginx-push-stream-module]# nginx -V
nginx version: nginx/1.4.4
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC)
TLS SNI support enabled
configure arguments: –prefix=/etc/nginx –sbin-path=/usr/sbin/nginx –conf-path=/etc/nginx/nginx.conf –error-log-path=/var/log/nginx/error.log –http-log-path=/var/log/nginx/access.log –pid-path=/var/run/nginx.pid –lock-path=/var/run/nginx.lock –http-client-body-temp-path=/var/cache/nginx/client_temp –http-proxy-temp-path=/var/cache/nginx/proxy_temp –http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp –http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp –http-scgi-temp-path=/var/cache/nginx/scgi_temp –user=nginx –group=nginx –with-http_ssl_module –with-http_realip_module –with-http_addition_module –with-http_sub_module –with-http_dav_module –with-http_flv_module –with-http_mp4_module –with-http_gunzip_module –with-http_gzip_static_module –with-http_random_index_module –with-http_secure_link_module –with-http_stub_status_module –with-mail –with-mail_ssl_module –with-file-aio –with-ipv6 –with-cc-opt=’-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector –param=ssp-buffer-size=4 -m64 -mtune=generic’ –add-module=/builddir/build/BUILD/nginx-1.4.4/nginx-push-stream-module-0.4.0[/bash]

Remember to save the above configuration.

Next, download nginx source for the above version and extract it:

[bash]wget http://nginx.org/download/nginx-1.4.4.tar.gz
tar xzvf nginx-1.4.4.tar.gz[/bash]

Next, download the nginx module we want to add:

[bash]wget https://github.com/wandenberg/nginx-push-stream-module/archive/master.zip
unzip master.zip
mv nginx-push-stream-module-master nginx-push-stream-module[/bash]

Finally, re-compile nginx with –add-module params:

[bash]cd nginx-1.4.4
./configure –prefix=/etc/nginx –sbin-path=/usr/sbin/nginx –conf-path=/etc/nginx/nginx.conf –error-log-path=/var/log/nginx/error.log –http-log-path=/var/log/nginx/access.log –pid-path=/var/run/nginx.pid –lock-path=/var/run/nginx.lock –http-client-body-temp-path=/var/cache/nginx/client_temp –http-proxy-temp-path=/var/cache/nginx/proxy_temp –http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp –http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp –http-scgi-temp-path=/var/cache/nginx/scgi_temp –user=nginx –group=nginx –with-http_ssl_module –with-http_realip_module –with-http_addition_module –with-http_sub_module –with-http_dav_module –with-http_flv_module –with-http_mp4_module –with-http_gunzip_module –with-http_gzip_static_module –with-http_random_index_module –with-http_secure_link_module –with-http_stub_status_module –with-mail –with-mail_ssl_module –with-file-aio –with-ipv6 –with-cc-opt=’-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector –param=ssp-buffer-size=4 -m64 -mtune=generic’ –add-module=/root/builddir/nginx-push-stream-module
make
sudo make install[/bash]

It’s done, check it with

[bash]nginx -V[/bash]

Trouble Shooting

1. Error

[bash]./configure: error: the HTTP rewrite module requires the PCRE library.[/bash]

. Fix it by

[bash]yum install pcre pcre-devel[/bash]

2. Error

[bash]./configure: error: SSL modules require the OpenSSL library.[/bash]

. Fix it by

[bash]yum install openssl-devel[/bash]

Leave a comment

Your email address will not be published. Required fields are marked *