Skip to content

Table of Content




nginx [engine x] is an HTTP and reverse proxy server, a mail proxy server, and a generic TCP/UDP proxy server, originally written by Igor Sysoev. For a long time, it has been running on many heavily loaded Russian sites including Yandex, Mail.Ru, VK, and Rambler. According to Netcraft, nginx served or proxied 20.71% busiest sites in January 2024. Here are some of the success stories: Dropbox, Netflix,, FastMail.FM.

The sources and documentation are distributed under the 2-clause BSD-like license.



Install mercurial and clone the repository.

# installation
$ sudo apt install mercurial
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
Suggested packages:
  kdiff3 | kdiff3-qt | kompare | meld | tkcvs | mgdiff qct python3-mysqldb python3-openssl python3-pygments
The following NEW packages will be installed:
  mercurial mercurial-common
0 upgraded, 2 newly installed, 0 to remove and 17 not upgraded.
Need to get 3103 kB of archives.
After this operation, 16.0 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 bookworm/main amd64 mercurial-common all 6.3.2-1 [2768 kB]
Get:2 bookworm/main amd64 mercurial amd64 6.3.2-1 [335 kB]
Fetched 3103 kB in 0s (13.5 MB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package mercurial-common.
(Reading database ... 32185 files and directories currently installed.)
Preparing to unpack .../mercurial-common_6.3.2-1_all.deb ...
Unpacking mercurial-common (6.3.2-1) ...
Selecting previously unselected package mercurial.
Preparing to unpack .../mercurial_6.3.2-1_amd64.deb ...
Unpacking mercurial (6.3.2-1) ...
Setting up mercurial-common (6.3.2-1) ...
Setting up mercurial (6.3.2-1) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/ line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/mercurial/hgrc.d/hgext.rc with new version

# location
$ which hg

# version
$ hg --version
Mercurial Distributed SCM (version 6.3.2)
(see for more information)

Copyright (C) 2005-2023 Olivia Mackall and others
This is free software; see the source for copying conditions. There is NO

# clone repository
$ hg clone
destination directory: nginx
requesting all changes
adding changesets
adding manifests
adding file changes
added 9208 changesets with 24688 changes to 755 files (+18 heads)
new changesets 4eff17414a43:73eb75bee30f
updating to branch default
503 files updated, 0 files merged, 0 files removed, 0 files unresolved


cd nginx

# list of branches
hg branches

# list of tags
hg tags

# latest tag
hg tags --pager never | head -2 | grep -v tip

# load the tagged version
hg update release-1.25.3

# configure --help
auto/configure --help

# create user - offical docker nginx creates user with 101
sudo groupadd --system --gid 244 nginx
sudo useradd --system --gid nginx --no-create-home --home /nonexistent --comment "nginx user" --shell /bin/false --uid 244 nginx

# install requirements
sudo apt install gcc openssl libpcre3 libpcre3-dev

# configure
auto/configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --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/ --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_v3_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -ffile-prefix-map=/data/builder/debuild/nginx-1.25.1/debian/debuild-base/nginx-1.25.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie'

# build and install / make
sudo make
sudo make install

# prepare temp directories specified in configure options
sudo mkdir /var/cache/nginx
cd /var/cache/nginx
sudo mkdir client_temp proxy_temp fastcgi_temp uwsgi_temp scgi_temp

# test and run/stop
sudo nginx -V
sudo nginx -t
sudo nginx
sudo nginx -s stop