2017-02-17 165 views

回答

4

最好從代碼中自己構建mod_wsgi,而不是在網絡中使用任意二進制。步驟如下。

  • 確保你有一個體面的Apache安裝,其中包括頭文件。最好安裝在C:/Apache24的位置。

  • 確保您的Python安裝已設置,以便您可以安裝pip模塊。這必須包括具有Python版本所需的正確Microsoft C編譯器。

  • 運行pip install mod_wsgi。如果您的Apache安裝不在C:/Apache24,則首先將環境變量MOD_WSGI_APACHE_ROOTDIR設置爲其位置。確保您指定的路徑爲C:/Apache24表單,而不是反斜線,即不是C:\Apache24。這隻在進行安裝時才需要,而不是在以後。

  • 運行mod_wsgi-express module-config

  • 將運行mod_wsgi-express module-config的輸出複製到您的Apache配置文件中。

  • 將WSGI應用程序的配置添加到Apache配置中。

  • 重新啓動Apache並查看它是否有效。

注意,你最好開始用WSGI你好世界,而不是在最初測試一些巨大的Django應用程序。

+0

Thanks.I開始學習Django而不是。現在使用他們的服務器 –

+0

當我運行'pip install mod_wsgi'時,它失敗,並且出現'c:\ apache24 \ include \ apr_network_io.h(29):致命錯誤C1083:無法打開include文件:'apr_perms_set.h':沒有這樣的文件或目錄'.'這是與httpd 2.4.27。任何想法如何解決這個問題? –

+0

上面的嘗試是從我從'http:// mirrors.gigenet.com/apache/httpd/httpd-2.4.27.tar.gz'下載的源代碼。我只是嘗試用github克隆的源代碼構建,並使用'c:\ apache24 \ include \ ap_hooks.h(39)失敗:致命錯誤C1083:無法打開包含文件:'apr.h':沒有這樣的文件或目錄' –

1
This topic is useful for Windows 10, xampp webserver as well. 
I was struggling to find precompiled mod_wsgi.so for 
Apache/2.4.27 (Win32) 
Python/2.7.13 
This [link][1] is useful to find the appropriate version of mod_wsgi. 
IF you are lucky, you can find the precompiled version [here][2] 
There is a step by step guidance available [here][3] 


    [1]: https://github.com/GrahamDumpleton/mod_wsgi/blob/develop/win32/README.rst 
    [2]: http://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi 
    [3]: https://everything2.com/title/Installing+Python+on+XAMPP 
+0

推薦的方法是使用''pip install mod_wsgi''作爲解釋在另一個答案中自己構建它。抓取任意二進制文件不能保證能正常工作。您應該爲您的特定Apache安裝構建它。 –

0

@LarryMartell 我在Windows上遇到同樣的問題,並修復它。 您可以嘗試從apr存儲庫(https://github.com/traviscross/apr)將文件apr_perms_set.h複製到Apache2.4的include文件夾。

+0

這並不回答原來的問題。如果問題是他們錯過了,則從單獨的回購庫複製APR頭文件也無法保證正常工作。使用Apache發行版來代替發送頭文件。如果您沒有使用與Apache編譯完全相同的頭文件,則可能會遇到問題。 –

0

使用Apache Lounge的版本,如果您還發現c:\apache24\include\apr_network_io.h(29) : fatal error C1083: Cannot open include file: 'apr_perms_set.h': No such file or directory'.。 這最適合Windows。