# Deploying newly compiled nginx from test server to production

**URL:** <https://www.ruby-forum.com/t/deploying-newly-compiled-nginx-from-test-server-to-production/242317>\
**Category:** NGINX\
**Created:** [June 15, 2015, 11:59am UTC](https://www.ruby-forum.com/t/deploying-newly-compiled-nginx-from-test-server-to-production/242317 "2015-06-15T11:59:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [June 15, 2015, 11:59am UTC](https://www.ruby-forum.com/t/deploying-newly-compiled-nginx-from-test-server-to-production/242317/1 "2015-06-15T11:59:44Z")

</div>

Hello

What is a good method for deploying a newly compiled nginx binary with  
an  
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  
mod\_sec).

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:

> **[Deploying newly compiled nginx from test server to production](https://forum.nginx.org/read.php?2,259622,259622#msg-259622)**
>
> Hello What is a good method for deploying a newly compiled nginx binary with an 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...

---

<div class="post-metadata">

**Author:** ![ajjH6](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ad7895/32.png) [@ajjH6](https://www.ruby-forum.com/u/ajjH6)\
**Post date:** [June 15, 2015, 2:39pm UTC](https://www.ruby-forum.com/t/deploying-newly-compiled-nginx-from-test-server-to-production/242317/2 "2015-06-15T14:39:13Z")

</div>

I would prefer RPM. Just patching the official one.

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

---

<div class="post-metadata">

**Author:** ![ajjH6](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ad7895/32.png) [@ajjH6](https://www.ruby-forum.com/u/ajjH6)\
**Post date:** [June 16, 2015, 5:59am UTC](https://www.ruby-forum.com/t/deploying-newly-compiled-nginx-from-test-server-to-production/242317/3 "2015-06-16T05:59:22Z")

</div>

Thanks ryd994.

I eventually build the RPM ok.

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

> **[How To Compile Nginx from Source on a CentOS 6.4 x64 VPS | DigitalOcean](https://www.digitalocean.com/community/tutorials/how-to-compile-nginx-from-source-on-a-centos-6-4-x64-vps)**
>
> Read how to compile Nginx from source on a CentOS 6.4 x64 VPS.

./configure   
–user=nginx   
–group=nginx   
–prefix=/etc/nginx   
–sbin-path=/usr/sbin/nginx   
–conf-path=/etc/nginx/nginx.conf   
–pid-path=/var/run/nginx.pid   
–lock-path=/var/run/nginx.lock   
–error-log-path=/var/log/nginx/error.log   
–http-log-path=/var/log/nginx/access.log   
–with-http\_gzip\_static\_module   
–with-http\_stub\_status\_module   
–with-http\_ssl\_module   
–with-pcre   
–with-file-aio   
–with-http\_realip\_module   
–without-http\_scgi\_module   
–without-http\_uwsgi\_module   
–without-http\_fastcgi\_module

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

%build  
./configure   
–prefix=%{\_sysconfdir}/nginx   
–sbin-path=%{\_sbindir}/nginx   
–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   
–user=%{nginx\_user}   
–group=%{nginx\_group}   
–with-http\_gzip\_static\_module   
–with-http\_stub\_status\_module   
–with-http\_ssl\_module   
–with-pcre   
–with-file-aio   
–with-http\_realip\_module   
–without-http\_scgi\_module   
–without-http\_uwsgi\_module   
–without-http\_fastcgi\_module   
%{?with\_spdy:–with-http\_spdy\_module}   
–with-cc-opt=“%{optflags} $(pcre-config --cflags)” \

–add-module=%{\_builddir}/%{name}-%{version}/modsecurity-2.9.0/nginx/modsecurity  
$\*

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  
–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 --user=nginx --group=nginx  
–with-http\_gzip\_static\_module --with-http\_stub\_status\_module  
–with-http\_ssl\_module --with-pcre --with-file-aio  
–with-http\_realip\_module  
–without-http\_scgi\_module --without-http\_uwsgi\_module  
–without-http\_fastcgi\_module --with-http\_spdy\_module --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=/home/test/rpmbuild/BUILD/nginx-1.8.0/modsecurity-2.9.0/nginx/modsecurity

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  
to  
determine what are the ramifications are here.

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,259622,259636#msg-259636](http://forum.nginx.org/read.php?2,259622,259636#msg-259636)

---

<div class="post-metadata">

**Author:** ![ajjH6](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ad7895/32.png) [@ajjH6](https://www.ruby-forum.com/u/ajjH6)\
**Post date:** [June 16, 2015, 5:55pm UTC](https://www.ruby-forum.com/t/deploying-newly-compiled-nginx-from-test-server-to-production/242317/4 "2015-06-16T17:55:02Z")

</div>

Congratulations for get the RPM.

If you search in spec file for “with\_spdy”, you should find that tag  
(think  
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  
of  
pcre lib.

If all you need is a static file server, I guess you can remove  
follwing:  
–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:  
[http://wiki.nginx.org/Modules](http://wiki.nginx.org/Modules)  
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  
you  
should rebuild and install apr first.

Regards,
