Deploying newly compiled nginx from test server to production


What is a good method for deploying a newly compiled nginx binary with
extra module? (mod_security)

I can get all to compile ok. However, I do not want to compile on my
production server. There are two many dependencies (ie HTTPD for

In the case of mod_security, it seems only the Apache Portable Runtime
(apr-util) is required if I manually move the binary over.

I tried building my own RPM but hit some issues.

Posted at Nginx Forum:

I would prefer RPM. Just patching the official one.

RPM patching process is pretty standardized and shouldn’t take more than
few minutes. Could you explain what problem you have?

Thanks ryd994.

I eventually build the RPM ok.

I am attempting to build a stripped down nginx RPM with minimal modules,
also with modsec. I found a suggested config at -


I was able to build the RPM with the following in the nginx.spec file -

–with-cc-opt=“%{optflags} $(pcre-config --cflags)” \


I am unsure on the a couple of lines at the bottom -

    %{?with_spdy:--with-http_spdy_module} \
    --with-cc-opt="%{optflags} $(pcre-config --cflags)" \

The RPM installs fine (apr-devel rpm dependency).

Version outputs the following -

nginx -V
nginx version: nginx/1.8.0
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx
–http-log-path=/var/log/nginx/access.log --pid-path=/var/run/
–lock-path=/var/run/nginx.lock --user=nginx --group=nginx
–with-http_gzip_static_module --with-http_stub_status_module
–with-http_ssl_module --with-pcre --with-file-aio
–without-http_scgi_module --without-http_uwsgi_module
–without-http_fastcgi_module --with-http_spdy_module --with-cc-opt=‘-O2
-pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
–param=ssp-buffer-size=4 -m64 -mtune=generic’

Basically I want a minimal nginx install to serve static files over SSL.
Might you have any suggestions to improve this?

I also found a separate issue which I discovered when modsec is compiled

“configure: WARNING: APR util was not compiled with crypto support.
SecRemoteRule will not support the parameter ‘crypto’”

Basically the rhel6 apr-devel rpm does not have crypto support. Trying
determine what are the ramifications are here.

Posted at Nginx Forum:

Congratulations for get the RPM.

If you search in spec file for “with_spdy”, you should find that tag
it as some variable) around.
I’m not quite sure about --with-cc-opt=“%{optflags} $(pcre-config
–cflags)”. Seems it is there to keep nginx compiled with same options
pcre lib.

If all you need is a static file server, I guess you can remove
–with-http_gzip_static_module (pre compressed file)
–with-http_stub_status_module (stub page might be used by some
monitoring tools, like longview)
–with-http_realip_module (parse X-Forwarded-For)
–with-pcre (regex)
If you want to rip off more, you can try add --without-* options:
Wiki is somewhat outdated. If you get invalid options, that module might
already excluded from default build. Don’t worry for that. Also, You can
always recompile again if you cut off too much. Shouldn’t take long.

I never used modsec before, so I can’t help with the APR issue. Maybe
should rebuild and install apr first.