私人论坛

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 4264|回复: 2

windows 下编译 nginx

[复制链接]

156

主题

303

帖子

1664

积分

新手上路

Rank: 1

积分
1664
发表于 2018-8-23 14:50:01 | 显示全部楼层 |阅读模式
参考:
https://github.com/wuyao721/51docs/blob/master/it/nginx-building-windows.org
http://nginx.org/en/docs/howto_build_on_win32.html

一、部署编译环境
安装 Microsoft Visual Studio
安装 MinGW
安装 Perl


二、部署源代码
1、下载 nginx 源码:
http://hg.nginx.org/nginx
http://hg.nginx.org/nginx/archive/tip.tar.gz

如果从
http://nginx.org/en/download.html
http://nginx.org/download/nginx-1.15.2.tar.gz
下载源代码,务必将 {
/nginx/src/os/win32/*
/nginx/src/event/modules/ngx_iocp_module.c
/nginx/src/event/modules/ngx_iocp_module.h
/nginx/src/event/ngx_event_acceptex.c

} 用上面的压缩包对应文件补全;

否则编译时会出现会出现:
NMAKE : fatal error U1073: 不知道如何生成“src/os/win32/ngx_win32_config.h”Stop.

2、解压到 /nginx ,创建 /nginx/objs/lib 文件夹

3、下载openssl
https://www.openssl.org/source/
https://www.openssl.org/source/openssl-1.1.1-pre9.tar.gz

下载pcre
http://www.pcre.org/
https://ftp.pcre.org/pub/pcre/
https://ftp.pcre.org/pub/pcre/pcre-8.42.zip

下载zlib
http://www.zlib.net/
http://www.zlib.net/zlib-1.2.11.tar.gz

下载nginx-http-flv-module
https://github.com/winshining/nginx-http-flv-module

4.解压到 /nginx/objs/lib 文件夹

5.修改 /nginx/auto/cc/msvc 文件
因为 MSVC 2017 对应 19.14,在
echo " + cl version: $NGX_MSVC_VER"
上一行加入一句
NGX_MSVC_VER=19.14

===== 压缩备份 _0 =====


三、配置、编译

5.在 /nginx/ 下打开命令提示符,分别执行:

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

"C:/MinGW/msys/1.0/msys.bat"

在新窗口中执行

./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-select_module --with-http_ssl_module \
--with-pcre=objs/lib/pcre-8.42 \
--with-zlib=objs/lib/zlib-1.2.11 \
--with-openssl=objs/lib/openssl-1.1.1-pre9 \
--add-module=objs/lib/nginx-http-flv-module

nmake -f objs/Makefile
或者
nmake -f Makefile
回复

使用道具 举报

156

主题

303

帖子

1664

积分

新手上路

Rank: 1

积分
1664
 楼主| 发表于 2019-2-28 01:35:53 | 显示全部楼层
一、部署编译环境
安装 Microsoft Visual Studio

安装 MinGW
https://sourceforge.net/projects/mingw/
  安装 mingw32-base、msys-base
安装 Perl
https://www.activestate.com/products/activeperl/downloads/
回复

使用道具 举报

156

主题

303

帖子

1664

积分

新手上路

Rank: 1

积分
1664
 楼主| 发表于 2019-2-28 19:05:43 | 显示全部楼层
error C2220: 警告被视为错误
删除 去掉 makefile 里面的 /WX
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|私人论坛

GMT+8, 2026-2-20 11:22 , Processed in 0.046385 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表