您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

windows平台下编译nginx相关问题处理

2024/6/14 7:42:36发布30次查看
本文讲述如何在windows下编译nginx,参考这篇文章 building nginx on the win32 platform with visual c ,它已经讲得比较详细了,但是实际操作过程中总有很多细节问题,在这里记录下来。
contents [hide]
1 常见问题1.1 获取指定版本1.2 “stdint.h”: no such file or directory1.3 “openssl/ssl.h”: no such file or directory1.4 无法打开文件 “objs/lib/openssl-1.0.1e/lib/ssleay32.lib”1.5 error c2220: 警告被视为错误 – 没有生成“object”文件1.6 fatal error c1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include “ngx_config.h””?1.7 每次编译的时候都完全编译2 操作流程总结常见问题
我使用的vs版本是vs2008,遇到了以下问题。
获取指定版本
有时候我们需要的不是最新版本,比如我要下载1.20版本的nignx,首先,我 这里 找1.20的版本号码,很快我找到是f582d662cc408eb7a132c21f4b298b71d0701abb,以下执行顺序就可以拿到指定版本:
hg clone http://hg.nginx.org/nginxcd nginxhg co f582d662cc408eb7a132c21f4b298b71d0701abb
“stdint.h”: no such file or directory
这个问题好办,下载缺少的头文件就行了。 https://code.google.com/p/msinttypes/
解压后将头文件目录 c:\program files\microsoft visual studio 9.0\vc\include 下面(或者类似的目录)。
“openssl/ssl.h”: no such file or directory
执行 nmake -f objs/makefile 的时候,可能会出现这样的问题。我们看到这样的路径(objs/lib/openssl-1.0.1e/openssl/include),其实是没有的。办法就是将openssl-1.0.1e/openssl改成openssl-1.0.1e。
vi nginx/objs/makefile或者直接修改生成makefile的配置
vi auto/lib/openssl/confvi auto/lib/openssl/make
无法打开文件 “objs/lib/openssl-1.0.1e/lib/ssleay32.lib”
不知道nginx项目为什么不生成openssl的库,我通过单独编译生成openssl来解决这个问题。步骤如下:
安装perl(我用activeperl)解压openssl到c盘,cd c:\openssl-1.0.1e执行perl configure vc-win32运行cmd,将 *”c:\program files\microsoft visual studio 9.0\vc\vcvarsall.bat”* 拉到cmd里运行cmd内执行 ms\do_mscmd内执行 nmake -f ms\ntdll.mak好了,将手工生成的 libeay32.lib 和 ssleay32.lib 放到目录 nginx/objs/lib/openssl-1.0.1e 下。问题解决。
error c2220: 警告被视为错误 – 没有生成“object”文件
将 cflags 的 -wx 字段去掉,然后重新生成makefile以及重新编译
vi auto/cc/msvc#cflags=$cflags -wx
fatal error c1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include “ngx_config.h””?
windows模块开发中会遇到的问题,每个源文件第一行代码必须添加 #include “ngx_config.h”* ,如果不想这样做就吧编译参数 *-yungx_config.h 去掉。
每次编译的时候都完全编译
执行这行代码的时候 nmake -f objs/makefile ,每次都要完全编译,好浪费时间啊。原因是这样的,文件 objs/makefile 里有这样一行:
objs/lib/openssl-1.0.1e/include/openssl/ssl.h: objs/makefilessh.h 文件依赖于 objs/makefile*,但是如果前者修改时间永远都比后者早,就永远都要执行后面的命令了。把字符串 *objs/makefile 去掉就行了。
操作流程总结
“c:\program files\microsoft visual studio 9.0\vc\vcvarsall.bat”“c:\mingw\msys\1.0\msys.bat”cd /c/nginx生成makefileauto/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 \--with-cc-opt=-dfd_setsize=1024 --with-pcre=objs/lib/pcre-8.32 \--with-zlib=objs/lib/zlib-1.2.7 --with-openssl=objs/lib/openssl-1.0.1e \--with-select_module --with-http_ssl_module --with-ipv6 \--add-module=objs/lib/naxsi-core-0.48/naxsi_src nmake -f objs/makefile启动nginxstart nginx.exe -p c:\nginxnginx.exe -p c:\nginx -s reloadnginx.exe -p c:\nginx -s quit参考资料:
windows下openssl安装配置
本文由吴遥编写,转载请注明出处。
文章链接:http://www.wuyao721.com/nginx-building-windows.html
以上就介绍了windows平台下编译nginx相关问题处理,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product