nginx-rtmp – Compile for Windows
If you want to try nginx with the rtmp module you can build it yourself, but with the latest updates I actually had severe problems building it under Windows and was not able to get a working product. You can still try it yourself using the following guide.
The nginx webserver can be compiled under Windows and other Operating Systems. To add modules, in this case the nginx-rtmp-module which allows you to run a rtmp server within nginx and gives you a lot of configuration options. HLS and Dash are also supported. But a few features of the rtmp module will not work under Windows. Personally I am only missing the “exec” function, which allows you to run ffmpeg for example to transcode your stream automatically, but its possible to work without it.
The ECSDS guys offer a ready to use version of nginx which, in older versions, included the rtmp module. Unfortunately their latest builds do not include the RTMP Module anymore. They now offer a paid version but you could also checkout MonaServer.
First of all we need grab a whole package of dependencies and tools:
Msys - http://www.mingw.org/wiki/MSYS I used mingw32 which includes an msys bash console Perl - http://www.activestate.com/activeperl I used Active Perl, while Strawberry Perl should also work Mercurial - https://www.mercurial-scm.org/ Client needed for hg clone etc. PCRE - http://www.pcre.org/ Recommended is version 8.35 ZLIB - http://zlib.net/ Recommended is version 1.2.8 OpenSSL - http://www.openssl.org/ Recommended is version 1.0.1g (earlier versions are vunerable to the Heartbleed bug)
hg clone http://hg.nginx.org/nginx
or you can use the homepage http://hg.nginx.org/nginx/tags, choose the tag you want to download and then click on “zip” in the left bar. If you did not use the “hg clone” commando you have to extract the downloaded zip file into your msys folder:
In the next step either download the zip file from https://github.com/arut/nginx-rtmp-module or use the git bash if you have one available to clone the current version of the nginx-rtmp-module using:
git clone http://github.com/arut/nginx-rtmp-module.git
Now inside the nginx source folder, create a subfolder called “objs”. Inside this folder create a folder called “lib”. We now extract each of our zip files to this subfolder so it finally looks like this:
nginx nginx\objs nginx\objs\lib nginx\objs\lib\pcre-8.35 nginx\objs\lib\zlib-1.2.8 nginx\objs\lib\openssl-1.0.1g nginx\objs\lib\nginx-rtmp-module
Of course you just move the cloned nginx-rtmp-module if you did not download the zip for it. Now we can create the make file before finally compiling nginx. The following is one full commando which can be typed or pasted in one line into the MSYS bash:
auto/configure --with-cc=cl --builddir=objs --prefix= --conf-path=conf/nginx.conf --pid-path=temp/nginx.pid --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-uwsgi-temp-path=temp/uwsgi_temp --http-scgi-temp-path=temp/scgi_temp --with-cc-opt=-DFD_SETSIZE=1024 --with-pcre=objs/lib/pcre-8.35 --with-zlib=objs/lib/zlib-1.2.8 --with-openssl=objs/lib/openssl-1.0.1g --with-select_module --with-http_ssl_module --add-module=objs/lib/nginx-rtmp-module
Note that we specify each of the libraries and the module with these commando as well as the normal nginx settings you can find on their windows documentation. You can change filepaths and other settings as well as add more modules than just the rtmp-module. But now its time to compile and see if we did everything correct. For this purpose we just need a Visual Studio Command Prompt. If you do not have Visual Studio lying around, you can grab the 2010 Express version for free. It adds a shortcut to your start menu to start the command prompt right away. Inside the command prompt use the normal “cd..” commandos to get into your nginx folder. (cd.. to move up, cd foldername to enter a folder) Inside the nginx folder you can start the compile process with this command:
nmake -f objs/Makefile
And even more tutorials can be found in the server section of our page. Good luck and have fun with nginx!