首頁  >  文章  >  後端開發  >  windows平台下編譯nginx相關問題處理

windows平台下編譯nginx相關問題處理

WBOY
WBOY原創
2016-08-08 09:26:571601瀏覽
本文講述如何在windows下編譯nginx,參考這篇文章 Building nginx on the Win32 platform with Visual C ,它已經講得比較詳細了,但是實際操作過程中總是有很多細節問題,在這裡記錄下來。

Contents [hide]

  • 1 
    • 1.1 取得指定版本
    • 1.2 「stdint.h」: No such file or directory
    • 1.3 「openssl/ssl.h」: No such file or directory
    • 1.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 2
我使用的VS版本是VS2008,遇到了下列問題。

取得指定版本

有時候我們需要的不是最新版本,例如我要下載1.20版本的nignx,首先,我 這裡 找1.20的版本號碼,很快我找到是f582666628820b以下執行順序就可以拿到指定版本:

hg clone http://hg.nginx.org/nginx cd nginx hg co f582d662cc408eb7a132c21f4b298b71d0701abb

“stdint.h”: No such file or directory

這個問題好辦,下載缺少的頭文件就行了。 https://code.google.com/p/msinttypes/

解壓縮後將頭檔目錄 C:Program FilesMicrosoft Visual Studio 9.0VCinclude 下方(或類似的目錄)。

「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/conf vi auto/lib/openssl/make

無法開啟檔案「objs/lib/openssl-1.0.1e/lib/ssleay32.lib」

函式庫,我透過單獨編譯產生openssl來解決這個問題。步驟如下:

安裝perl(我用ActivePerl)

解壓openssl到C盤,cd C:openssl-1.0.1e

解壓openssl到C盤,cd C:openssl-1.0.1e

執行perl Configure VC-WIN32
  • Studio 9.0VCvcvarsall.BAT」* 拉到cmd裡運行
  • cmd內執行msdo_ms
  • cmd內執行nmake -f msntdll.mak
  • /objs/lib/openssl-1.0.1e 下。問題解決。

error C2220: 警告被視為錯誤– 沒有產生「object」檔案

將 CFLAGS 的 -W error C1010 : 在尋找預編譯頭時遇到意外的檔案結尾。是否忘記了在來源中加入「#include 「ngx_config.h」”?

windows模組開發中會遇到的問題,每個原始檔案第一行程式碼必須加入 #include “ngx_config.h”* ,如果不想這樣做就吧編譯參數*- Yungx_config.h 去掉。這樣的,檔案 objs/Makefile 裡有一個這樣一行:

vi auto/cc/msvc #CFLAGS="$CFLAGS -WX" ssh.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
  • 生成makefile
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 \ --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
  • 启动nginx
start nginx.exe -p "C:\nginx" nginx.exe -p "C:\nginx" -s reload nginx.exe -p "C:\nginx" -s quit

参考资料:
Windows下OpenSSL安装配置

本文由吴遥编写,转载请注明出处。
文章链接:http://www.wuyao721.com/nginx-building-windows.html

以上就介绍了windows平台下编译nginx相关问题处理,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn