Compile Nginx 64bit in Windows

Nginx is a well known webservice software, people usually use lnmp/lamp(linux nginx/apache mysql php) as Web server environment. This time I will try to make a simply index service for windows to provide download service. The Nginx has it’s basic index service named autoindex, but the layout is so bad, it didn’t provide any search service. I found a alternative index service fancyindex, it can elegant finish such work.


compile environment:

  • MSYS environment (or MSYS2)
  • Microsoft Visual Studio, usually requires version 2008 and above, I will use 2017 here.
  • Perl environment, it will be use to compile openssl, we can use Strawberry Perl or ActivePerl.
  • Mercurial and Git
  • nasm, ASM optimize package

nasm is optional, when nasm not exist, you have to disable assembler optimize.

get the source code:

nginx source code:

the source code for windows needs to be clone with Mercurial:

hg clone 

this step can be finished with CMD or MSYS.

other libs and additional modules:

download PCREzlib and OpenSSL, and uncompress them(following code should be run in MSYS terminal):


mkdir -p objs/lib
cd objs/lib
tar -xzf ../../pcre-8.42.tar.gz
tar -xzf ../../zlib-1.2.11.tar.gz
tar -xzf ../../openssl-1.0.2q.tar.gz

clone fanxyindex source code


git clone ngx-fancyindex

Edit configuration for compiling:

Edit configuration for openssl (when you need to compile 64bit executable):


# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
    cd $(OPENSSL)
    perl Configure VC-WIN64A no-shared                  \
        --prefix="%cd%/openssl"                         \
        --openssldir="%cd%/openssl/ssl"                 \
    if exist ms\do_win64a.bat (                         \
        ms\do_win64a                                    \
        && $(MAKE) -f ms\nt.mak                         \
        && $(MAKE) -f ms\nt.mak install                 \
    ) else (                                            \
        $(MAKE)                                         \
        && $(MAKE) install_sw                           \

Change warning level:

the default warning level may cause unexpected abort when compiling. So we can edit nginx\auto\cc\msvc (about line 83):


# warnings

add msvc linker version:

you will see a warning if you don’t add this parameter “auto/cc/msvc: line 117: [: : integer expression expected”, this will not affect the compile (about line 17)


NGX_MSVC_VER=19.12 # MSVC 2017 (15.5.7)  cl 19.12
echo " + cl version: $NGX_MSVC_VER"

delete edit of manpage:

the Windows CMD or powershell don’t have a sed command, it may cause a error, nginx\objs\Makefile (about line 1762):


manpage:    objs/nginx.8
objs/nginx.8:   docs/man/nginx.8 objs/ngx_auto_config.h
    #sed -e "s|%%PREFIX%%||" \
        #-e "s|%%PID_PATH%%|/logs/|" \
        #-e "s|%%CONF_PATH%%|/conf/nginx.conf|" \
        #-e "s|%%ERROR_LOG_PATH%%|/logs/error.log|" \
        #< docs/man/nginx.8 > $@



run config with MSYS, the configuration is the same as Nginx official website with extra fancyindex module:


auto/configure \
--with-cc=cl \
--builddir=objs \
--with-debug \
--prefix= \
--conf-path=conf/nginx.conf \
--pid-path=logs/ \
--http-log-path=logs/access.log \
--error-log-path=logs/error.log \
--sbin-path=nginx.exe \
--http-client-body-temp-path=temp/client_body_temp \
--http-proxy-temp-path=temp/proxy_temp \
--http-fastcgi-temp-path=temp/fastcgi_temp \
--http-scgi-temp-path=temp/scgi_temp \
--http-uwsgi-temp-path=temp/uwsgi_temp \
--with-cc-opt=-DFD_SETSIZE=1024 \
--with-pcre=objs/lib/pcre-8.42 \
--with-zlib=objs/lib/zlib-1.2.11 \
--with-select_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_stub_status_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_slice_module \
--with-mail \
--with-stream \
--with-openssl=objs/lib/openssl-1.0.2q \
--with-http_ssl_module \
--with-mail_ssl_module \
--with-stream_ssl_module \

you should add following parameter when you don’t have nasm




after configuration, you can compile the executable file with MSVC tool-chain:
for 64bit os, you can use 64 Native Tools Command Prompt for VS 2017, add path for nasm before compile:


"C:\Program Files\NASM\nasmpath.bat"



nmake /f objs\MakeFile

you can have a cup of coffee now.

In the end, you can find the nginx.exe in the folder. The useage of fancyindex can be found there Link


, ,
Previous Post
Compile rtorrent-0.9.4 in ubuntu 18.04

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.

This site uses Akismet to reduce spam. Learn how your comment data is processed.