Skip to content

Building NGINX

aborkar-ibm edited this page Oct 5, 2018 · 48 revisions

Building NGINX

Below versions of NGINX are available in respective distributions at the time of creation of these build instructions:

  • Ubuntu 16.04 has 1.10.3
  • Ubuntu 18.04 has 1.14.0
  • SLES 15 has 1.14.0

The instructions provided below specify the steps to build NGINX version 1.14.0 on Linux on IBM Z for following distributions:

  • RHEL (6.10, 7.3, 7.4, 7.5)
  • SLES 12 SP3
  • Ubuntu 16.04

General Notes:

  • When following the steps below please use a standard permission user unless otherwise specified.
  • A directory /<source_root>/ will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it.

Step 1 : Building and Installing NGINX

1.1) Install dependencies

  • RHEL (6.10, 7.3, 7.4, 7.5)

    sudo yum install -y pcre-devel wget tar xz gcc make zlib-devel
    
  • SLES 12 SP3

    sudo zypper install -y pcre-devel wget tar xz gcc make zlib-devel
    
  • Ubuntu 16.04

    sudo apt-get update
    sudo apt-get install -y  wget tar gcc make libpcre3-dev openssl libssl-dev
    

1.2) Download and unpack the NGINX 1.14.0 source package

mkdir /<source_root>/
cd /<source_root>/
wget http://nginx.org/download/nginx-1.14.0.tar.gz
tar xvf nginx-1.14.0.tar.gz
cd nginx-1.14.0

1.3) Build and install NGINX

./configure
make
sudo make install

Note: NGINX will be installed in /usr/local/nginx/sbin/; depending upon user preferences and conventions, it may be necessary to either update PATH or create links to the executable files.

Step 2: Testing

Simple Proxy Test

2.1) Prepare a test webpage index.html to serve in /tmp/ folder.

For example, this simple HTML document provides a bare minimum of text:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
     <title>Test HTML File</title>
     <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    </head>
    <body>
     <p>This is a very simple HTML file.</p>
    </body>
    </html>

2.2) Create a file nginx.conf with following contents in /tmp/ folder.

This is a simple test of NGINX's proxy functionality, with NGINX serving as a proxy between an HTTP user and the webpage:

    worker_processes     3;
    error_log            logs/error.log;
    pid                  logs/nginx.pid;
    worker_rlimit_nofile 8192;

    events
    {
    worker_connections  2048;
    }

    http
    {
    index index.html index.htm index.php;

    default_type application/octet-stream;
    log_format   main '$remote_addr - $remote_user [$time_local]  $status '
       '"$request" $body_bytes_sent "$http_referer" '
       '"$http_user_agent" "$http_x_forwarded_for"';
    access_log   logs/access.log  main;
    sendfile     on;
    tcp_nopush   on;
    server_names_hash_bucket_size 128;

    server
    {
     listen 8080;
     root /tmp;
     location /
     {
     }
    }
    server {
     location / {
     proxy_pass http://localhost:8080/;
     }
    }
    }

This assumes that the webpage from step 1 is stored in /tmp/index.html. If this is not the case, modify the definitions for root and index accordingly.

2.3) Run NGINX with the provided configuration.

    /usr/local/nginx/sbin/nginx -c /tmp/nginx.conf

Note that this will normally need to be done as root, or NGINX will not have authority to access one or more ports, such as 80 and 8080.

Navigate a web browser to the address of the server running NGINX. The browser should display the webpage specified in index.html.

Step 3: NGINX Ingress Controller for Kubernetes (Optional)

Instructions for building NGINX Ingress Controller for Kubernetes can be found here .

References:

Clone this wiki locally