# Building nginx from Source on Windows

**URL:** <https://www.ruby-forum.com/t/building-nginx-from-source-on-windows/243725>\
**Category:** NGINX\
**Created:** [December 27, 2015, 7:15am UTC](https://www.ruby-forum.com/t/building-nginx-from-source-on-windows/243725 "2015-12-27T07:15:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [December 27, 2015, 7:15am UTC](https://www.ruby-forum.com/t/building-nginx-from-source-on-windows/243725/1 "2015-12-27T07:15:02Z")

</div>

Hi,

I posted a question at

> <https://stackoverflow.com/questions/34478016/building-nginx-from-source-on-windows>

– copied below:

I’m trying to build nginx from source on Windows. I got the following  
done:

1. Installed mingw, gcc, and msys

2. Downloaded the nginx source code

3. Ran the following in the msys console from the nginx source folder:

|$ auto/configure --with-cc=gcc --without-http\_rewrite\_module  
–without-http\_gzip\_module (output omitted) $ make -f objs/Makefile  
(output omitted) $ make install -f objs/Makefile (output omitted) |

This produced the nginx.exe file in the objs folder, but when I tried to  
run it I get the following error:

|$ nginx.exe nginx: [alert] could not open error log file: CreateFile()  
“/usr/local/nginx/logs/error.log” failed (3: The system cannot find the  
path specified) 2015/12/26 21:49:25 [emerg] 10200#9700: CreateFile()  
“/usr/local/nginx/conf/nginx.conf” failed (3: The system cannot find the  
path specified) |

But when I run|ls /usr/local/nginx|I see that  
the|conf|and|logs|directories are there, and the conf directory has some  
files in it:

|$ ls -l conf total 34 -rw-r–r-- 1 Admin Administrators 1077 Dec 26  
21:30 fastcgi.conf -rw-r–r-- 1 Admin Administrators 1077 Dec 26 21:30  
fastcgi.conf.default -rw-r–r-- 1 Admin Administrators 1007 Dec 26 21:30  
fastcgi\_params -rw-r–r-- 1 Admin Administrators 1007 Dec 26 21:30  
fastcgi\_params.default -rw-r–r-- 1 Admin Administrators 2837 Dec 26  
21:30 koi-utf -rw-r–r-- 1 Admin Administrators 2223 Dec 26 21:30  
koi-win -rw-r–r-- 1 Admin Administrators 3957 Dec 26 21:30 mime.types  
-rw-r–r-- 1 Admin Administrators 3957 Dec 26 21:30 mime.types.default  
-rw-r–r-- 1 Admin Administrators 2656 Dec 26 21:30 nginx.conf  
-rw-r–r-- 1 Admin Administrators 2656 Dec 26 21:30 nginx.conf.default  
-rw-r–r-- 1 Admin Administrators 636 Dec 26 21:30 scgi\_params  
-rw-r–r-- 1 Admin Administrators 636 Dec 26 21:30 scgi\_params.default  
-rw-r–r-- 1 Admin Administrators 664 Dec 26 21:30 uwsgi\_params  
-rw-r–r-- 1 Admin Administrators 664 Dec 26 21:30 uwsgi\_params.default  
-rw-r–r-- 1 Admin Administrators 3610 Dec 26 21:30 win-utf |

I tried to run|$ chmod -R 0777 conf|but that did not seem to make a  
difference.

What am I doing wrong? And how can I change it so that the logs and conf  
files will be searched in the local directory of nginx.exe and not in  
the|/usr/local/nginx folder|(which I found after some searching  
at|msys\1.0\local\nginx|)?

Thanks!

–

Igal Sapir  
Lucee Core Developer  
[Lucee.org](http://Lucee.org) [http://lucee.org/](http://lucee.org/)

---

<div class="post-metadata">

**Author:** ![Igal\_S\_Lucee.org](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/6f9a4e/32.png) [@Igal\_S\_Lucee.org](https://www.ruby-forum.com/u/Igal_S_Lucee.org)\
**Post date:** [December 27, 2015, 8:44pm UTC](https://www.ruby-forum.com/t/building-nginx-from-source-on-windows/243725/2 "2015-12-27T20:44:40Z")

</div>

update: so I ran the following command:

auto/configure --with-cc=gcc --prefix= --conf-path=conf/nginx.conf  
–pid-path=nginx.pid --http-log-path=logs/access.log  
–error-log-path=logs/error.log–without-http\_gzip\_module  
–without-http\_rewrite\_module

and it creates the objs/Makefile (35kb) and Makefile (1kb) and directory  
structure of the sources. there is also an autoconf.err file with a  
single line in it: checking for gcc -pipe switch

running:

make -f objs/Makefile

populates the directory structure with .o files, and produces nginx.exe  
which is about 3.14 MB (3,293,712 bytes). can I just use that file or  
do I still need to run “make install”? running

make install -f objs/Makefile

generates an error:

test -d ‘’ || mkdir -p ‘’  
mkdir: `’: No such file or directory  
make: \*\*\* [install] Error 1

running the nginx.exe file creates two processes named nginx, but  
requests to localhost:8080 (I changed the port in nginx.conf) hang, and  
error.log shows the following:

2015/12/27 11:22:48 [alert] 10032#9464: GetQueuedCompletionStatus()  
returned operation error (1236: The network connection was aborted by  
the local system)  
2015/12/27 11:22:48 [alert] 10032#9464: \*1 connection already closed  
while waiting for request, client: 127.0.0.1, server: 0.0.0.0:8080

---

<div class="post-metadata">

**Author:** ![Igal\_S\_Lucee.org](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/6f9a4e/32.png) [@Igal\_S\_Lucee.org](https://www.ruby-forum.com/u/Igal_S_Lucee.org)\
**Post date:** [December 28, 2015, 3:53pm UTC](https://www.ruby-forum.com/t/building-nginx-from-source-on-windows/243725/3 "2015-12-28T15:53:45Z")

</div>

Hello!

On Sun, Dec 27, 2015 at 11:44:16AM -0800, Igal @ [Lucee.org](http://Lucee.org) wrote:

> update: so I ran the following command:
> 
> auto/configure --with-cc=gcc --prefix= --conf-path=conf/nginx.conf  
> –pid-path=nginx.pid --http-log-path=logs/access.log  
> –error-log-path=logs/error.log–without-http\_gzip\_module  
> –without-http\_rewrite\_module

The “–with-select\_module” option is missing, and that’s what  
causes your troubles.

[…]

> populates the directory structure with .o files, and produces nginx.exe  
> which is about 3.14 MB (3,293,712 bytes). can I just use that file or do I  
> still need to run “make install”? running

Running “make install” won’t do anything good with an empty  
prefix. Just run the nginx.exe binary.

See also this howto article:

> **[Building nginx on the Win32 platform with Visual C](http://nginx.org/en/docs/howto_build_on_win32.html)**

It describes how to build nginx using MS Visual C as currently  
done for official win32 builds.

–  
Maxim D.

> **[nginx](http://nginx.org/)**

---

<div class="post-metadata">

**Author:** ![Igal\_S\_Lucee.org](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/6f9a4e/32.png) [@Igal\_S\_Lucee.org](https://www.ruby-forum.com/u/Igal_S_Lucee.org)\
**Post date:** [December 28, 2015, 8:45pm UTC](https://www.ruby-forum.com/t/building-nginx-from-source-on-windows/243725/4 "2015-12-28T20:45:15Z")

</div>

Thank you, Maxim!

I prefer to build with gcc if that is possible. MS Visual C is a mess  
IMO. As a Java developer I’m used to more intuitive tools and options,  
I guess.

I will try to add --with-select\_module and hopefully that will do the  
trick. I will report back once I have some findings.

---

<div class="post-metadata">

**Author:** ![Igal\_S\_Lucee.org](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/6f9a4e/32.png) [@Igal\_S\_Lucee.org](https://www.ruby-forum.com/u/Igal_S_Lucee.org)\
**Post date:** [December 28, 2015, 8:49pm UTC](https://www.ruby-forum.com/t/building-nginx-from-source-on-windows/243725/5 "2015-12-28T20:49:56Z")

</div>

Hello!

On Mon, Dec 28, 2015 at 11:44:32AM -0800, Igal @ [Lucee.org](http://Lucee.org) wrote:

> Thank you, Maxim!
> 
> I prefer to build with gcc if that is possible. MS Visual C is a mess IMO.  
> As a Java developer I’m used to more intuitive tools and options, I guess.
> 
> I will try to add --with-select\_module and hopefully that will do the trick.  
> I will report back once I have some findings.

MinGW’s gcc is expected to work fine as well. The difference is  
that you have to specify --with-cc=gcc (instead of cl) and run  
make instead of nmake.

–  
Maxim D.

> **[nginx](http://nginx.org/)**

---

<div class="post-metadata">

**Author:** ![Igal\_S\_Lucee.org](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/6f9a4e/32.png) [@Igal\_S\_Lucee.org](https://www.ruby-forum.com/u/Igal_S_Lucee.org)\
**Post date:** [December 3, 2016, 7:31pm UTC](https://www.ruby-forum.com/t/building-nginx-from-source-on-windows/243725/6 "2016-12-03T19:31:52Z")

</div>

Hey! I found an updated guide on how to install nginx from source code  
here

> **[Install nginx from source code](https://tutorials.technology/tutorials/00-install-nginx-from-source.html)**
>
> Learn how to setup up a nginx server from the source code.
