准备工作
要在 Microsoft Win32??平台上编译Nginx你需要:
- Microsoft Visual C compiler. Microsoft Visual Studio??8 and 10 are known to work.(用来编译)
- MSYS.(执行配置脚本)
- Perl, if you want to build OpenSSL??and nginx with SSL support. For example?ActivePerl?or?Strawberry Perl.(注意这里不能使用MSYS的perl)
- Mercurial?client.(通过HG下载最新源码)
- PCRE,?zlib?and?OpenSSL?libraries sources.(PCRE用来重写url,zlib支持页面压缩,这里编译rtmp模块,必须编译出openssl)
- win32版nginx-rtmp-module模块源代码
编译步骤
在开始之前,你需要将Perl,Mercurial,MSYS bin目录加入PATH环境变量,也就是打开cmd,输入perl,hg,bash不会提示找不到命令.运行vcvarsall.bat或者叫Visual Studio命令提示(2010).
- 敲入bash,进入msys的环境
- 从hg.nginx.org检出最新的Nginx源代码
hg clone http://hg.nginx.org/nginx
- Create a build and lib directories, and unpack zlib, PCRE and OpenSSL libraries sources into lib directory: 创建一个编译和库目录,并且解压zlib,PCRE,OpenSSL,git回win32分支的nginx-rtmp-module模块
mkdir objs/lib -p cd objs/lib tar -xzf pcre-8.32.tar.gz tar -xzf zlib-1.2.8.tar.gz tar -xzf openssl-1.0.1e.tar.gz unzip nginx-rtmp-module-win32.zip (也可使用git)
- 回到nginx主目录,运行配置脚本
auto/configure --with-cc=cl --builddir=objs --prefix= --conf-path=conf/nginx.conf --pid-path=logs/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-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.32 --with-zlib=objs/lib/zlib-1.2.8 --with-openssl=objs/lib/openssl-1.0.1e --with-select_module --with-http_ssl_module --add-module=objs/lib/nginx-rtmp-module-win32
- 编译
nmake -f objs/Makefile
成功后会在objs目录内生成nginx.exe文件,创建conf,logs,temp,tmp目录,将nginx-rtmp-module-win32/test/nginx.conf拷贝到conf目录,运行nginx.exe
使用任意rtmp客户端测试,默认app为myapp的直播应用,请参考官方配置开启record,vod等功能.
注意事项:
由于原作者是在*UNIX环境开发,使用了部分UNIX系统调用,部分功能在windows上暂时无法实现,比如vod 为mp4文件,exec ffmpeg来切片.但作为直播流,点播flv文件,在线录制是没有问题的.
下载撸主的编译版本:
nginx 1.7.10
nginx-rtmp-module 1.1.6
https://github.com/illuspas/nginx-rtmp-win32?
原创文章,转载请注明: 转载自贝壳博客
本文链接地址: 编译windows版nginx-rtmp-module