Windows编译Nginx及nginx-rtmp-module

参考文章:

https://blog.csdn.net/longji/article/details/52369618

最近因处理漏洞问题重新编译了Windows的Nginx,有一些坑记录下来,以便以后回查。

大部分流程参考上面的这个文章。

源码下载最好是http://hg.nginx.org/nginx/在这里下载。用hg也可以,只是个人觉得不方便。

所用OpenSSL为1.1.0h,zlib为1.2.11,pcre为8.39

Nginx为1.17.6

进入C盘msys目录,双击msys.bat打开mingw32的窗口

cd到nginx的目录

编译配置命令

auto/configure --with-cc=cl --builddir=build --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=build/lib/pcre-8.39 \
--with-zlib=build/lib/zlib-1.2.11 --with-openssl=build/lib/openssl-1.1.0h \
--with-select_module --with-http_ssl_module \
--with-http_sub_module \
--add-module=build/lib/nginx-rtmp-module-1.2.1

提示 auto/cc/msvc: line 117: [: : integer expression expected

则修改文件nginx源码目录\auto\cc\msvc 即可,在 echo " + cl version: $NGX_MSVC_VER" 的前面加入一行 NGX_MSVC_VER=15.00

开始编译:

另开一个cmd窗口

我使用的是VS2017,执行如下命令初始化环境。

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat"

#然后

nmake -f build/Makefile

#开始编译

其他参考:

https://blog.csdn.net/silent_missile/article/details/99317811

https://blog.csdn.net/u010505059/article/details/92661913

发布了17 篇原创文章 · 获赞 6 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/wangjingkaibear/article/details/103560009