NOTE
1.4 Build and Install
Nginx source build and installation, startup, parameters, and directory layout.
This is a historical learning note and may contain outdated or incomplete understanding.
1. Setup Steps
1.1. Download
-
Nginx nginx: download
-
Other source dependencies
mkdir src
cd src
# PCRE version 4.4 - 8.40
wget https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gz && tar xzvf pcre-8.40.tar.gz
# zlib version 1.1.3 - 1.2.11
wget http://www.zlib.net/zlib-1.2.11.tar.gz && tar xzvf zlib-1.2.11.tar.gz
# OpenSSL version 1.0.2 - 1.1.0
wget https://www.openssl.org/source/openssl-1.1.0f.tar.gz && tar xzvf openssl-1.1.0f.tar.gz
# Lua environment
wget http://luajit.org/download/LuaJIT-2.0.2.tar.gz && tar xzvf LuaJIT-2.0.2.tar.gz
wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz && tar xzvf v0.3.0.tar.gz
wget https://github.com/openresty/lua-nginx-module/archive/v0.10.9rc7.tar.gz && tar xzvf v0.10.9rc7.tar.gz
1.2. Install the Development Environment
sudo apt install build-essential -y
sudo apt-get install libxml2 libxml2-dev libxslt1-dev -y
sudo apt-get install -y libgd-dev
sudo apt-get install -y libgeoip-dev
sudo apt-get install lua5.3 -y
export LUAJIT_LIB=/usr/local/luajit/lib
export LUAJIT_INC=/usr/local/luajit/include/luajit-2.0
1.3. Build and Install
./configure --prefix=<USER_HOME>/software/nginx/nginx \
--sbin-path=<USER_HOME>/software/nginx/nginx/sbin/nginx \
--modules-path=<USER_HOME>/software/nginx/nginx/modules \
--conf-path=<USER_HOME>/software/nginx/nginx/conf/nginx.conf \
--error-log-path=<USER_HOME>/software/nginx/nginx/log/error.log \
--pid-path=<USER_HOME>/software/nginx/nginx/log/nginx.pid \
--lock-path=<USER_HOME>/software/nginx/nginx/log/nginx.lock \
--user=<USER> \
--group=wheel \
--with-select_module \
--with-poll_module \
--with-threads \
--with-file-aio \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_xslt_module=dynamic \
--with-http_image_filter_module=dynamic \
--with-http_geoip_module=dynamic \
--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_auth_request_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_degradation_module \
--with-http_slice_module \
--with-http_stub_status_module \
--http-log-path=<USER_HOME>/software/nginx/nginx/log/access.log \
--http-client-body-temp-path=<USER_HOME>/software/nginx/nginx/temp/client_temp \
--http-proxy-temp-path=<USER_HOME>/software/nginx/nginx/temp/proxy_temp \
--http-fastcgi-temp-path=<USER_HOME>/software/nginx/nginx/temp/fastcgi_temp \
--http-uwsgi-temp-path=<USER_HOME>/software/nginx/nginx/temp/uwsgi_temp \
--http-scgi-temp-path=<USER_HOME>/software/nginx/nginx/temp/scgi_temp \
--with-mail=dynamic \
--with-mail_ssl_module \
--with-stream=dynamic \
--with-stream_ssl_module \
--with-stream_realip_module \
--with-stream_geoip_module=dynamic \
--with-stream_ssl_preread_module \
--with-compat \
--with-pcre=<USER_HOME>/software/nginx/src/pcre-8.40 \
--with-pcre-jit \
--with-zlib=<USER_HOME>/software/nginx/src/zlib-1.2.11 \
--with-openssl=<USER_HOME>/software/nginx/src/openssl-OpenSSL_1_0_2u \
--with-openssl-opt=no-nextprotoneg \
--add-module=<USER_HOME>/software/nginx/src/ngx_devel_kit-0.3.0 \
--add-module=<USER_HOME>/software/nginx/src/lua-nginx-module-0.10.9rc7 \
--with-debug
make -j2 && make install
1.4. Start
sudo nginx -c conf/nginx.conf
2. View the Parameters Selected During Installation
nginx -V
3. Directory Overview

Discussion
Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub