Mastering Nginx

(Ron) #1

Installing NGINX and Third-Party Modules


[ 10 ]

Preparing a build environment


In order to compile NGINX from source, certain requirements need to be met on your


system. Besides a compiler, you also need the OpenSSL and PCRE (Perl Compatible
Regular Expressions) libraries and development headers, if you want to enable the


SSL support and be able to use the rewrite module, respectively. Depending on
your system, these requirements may already be met in the default installation. If not,


you will need to either locate the appropriate package and install it, or download the


source, unpack it, and point NGINX's configure script to this location.


NGINX will attempt to build a dependent library statically if you include a –with-


= option to configure. You might want this if you would like to

ensure that NGINX is not dependent on any other part of the system and/or would


like to squeeze that extra bit of performance out of your nginx binary. If you are
using features of external libraries that are only available from a certain version


onwards (for example, the Next Protocol Negotiation TLS extension available from
OpenSSL Version 1.0.1), then you would have to specify the path to the unpacked


sources of that particular version.


There are other, optional, packages that you may provide support for if you like.


These include MD5 and SHA-1 hashing algorithm support, zlib compression,
and libatomic library support. The hashing algorithms are used in many places in


NGINX, for example, to compute the hash of a URI to determine a cache key. The zlib


compression library is used for delivering gzipped content. If the atomic_ops library
is available, NGINX will use its atomic memory update operations to implement


high-performance memory-locking code.


Compiling from source


NGINX may be downloaded from http://nginx.org/en/download.html.
Here you will find the source of either branch in the .tar.gz or .zip format.


Unpack the archive into a temporary directory as follows:


$ mkdir $HOME/build


$ cd $HOME/build && tar xzf nginx-.tar.gz


Configure it using the following command:


$ cd $HOME/build/nginx- && ./configure


And compile it as follows:


$ make && sudo make install

Free download pdf