2017-06-14 32 views
0

有人可以幫我,說最新錯了嗎?我需要使用Django + Apache如何在Apache中使用Django?

當我試圖啓動Apache時它爲我的錯誤:The requested operation has failed.

我試圖改變Listen 80不同的值,但它沒有幫助。 (如果沒有這些設置Apache的啓動罰款)將旁邊設置httpd.conf文件後,也會出現此錯誤:

LoadModule wsgi_module modules/mod_wsgi.so 
# Virtual hosts 
Include conf/extra/httpd-vhosts.conf 

我用:

1)的Apache 2.4(x64)的

2)的Python 3.5。 2(64)

3)的Django 1.10.5

4)的mod_wsgi-4.5.15 + ap24vc14-CP35-cp35m-win_amd64.whl

5)Windows 8.1(x64)

也許我用錯了mod_wsgi?我從mod_wsgi‑4.5.15+ap24vc14‑cp35‑cp35m‑win_amd64.whl歸檔文件取mod_wsgi.cp35-win_amd64.pyd文件並將該文件重命名爲mod_wsgi.so。之後,將該文件放到Apache的模塊文件夾中。

error.log中文件看起來像這樣:

[Wed Jun 14 21:42:30.381146 2017] [mpm_winnt:notice] [pid 11892:tid 692] AH00455: Apache/2.4.2 (Win64) configured -- resuming normal operations 
[Wed Jun 14 21:42:30.381146 2017] [mpm_winnt:notice] [pid 11892:tid 692] AH00456: Server built: May 11 2012 20:42:30 
[Wed Jun 14 21:42:30.381146 2017] [core:notice] [pid 11892:tid 692] AH00094: Command line: 'C:\\Program Files\\Apache2.4\\bin\\httpd.exe -d C:/Program Files/Apache2.4 -f C:\\Program Files\\Apache2.4\\conf\\httpd.conf -d C:\\Program Files\\Apache2.4\\.' 
[Wed Jun 14 21:42:30.381146 2017] [mpm_winnt:notice] [pid 11892:tid 692] AH00418: Parent: Created child process 13624 
[Wed Jun 14 21:42:30.646739 2017] [mpm_winnt:notice] [pid 13624:tid 328] AH00354: Child: Starting 64 worker threads. 
[Wed Jun 14 21:42:40.736467 2017] [mpm_winnt:notice] [pid 11892:tid 692] AH00422: Parent: Received shutdown signal -- Shutting down the server. 
[Wed Jun 14 21:42:42.759516 2017] [mpm_winnt:notice] [pid 13624:tid 328] AH00364: Child: All worker threads have exited. 
[Wed Jun 14 21:42:42.775140 2017] [mpm_winnt:notice] [pid 11892:tid 692] AH00430: Parent: Child process exited successfully. 
[Wed Jun 14 21:42:51.755536 2017] [mpm_winnt:notice] [pid 7988:tid 696] AH00455: Apache/2.4.2 (Win64) configured -- resuming normal operations 
[Wed Jun 14 21:42:51.756537 2017] [mpm_winnt:notice] [pid 7988:tid 696] AH00456: Server built: May 11 2012 20:42:30 
[Wed Jun 14 21:42:51.756537 2017] [core:notice] [pid 7988:tid 696] AH00094: Command line: 'C:\\Program Files\\Apache2.4\\bin\\httpd.exe -d C:/Program Files/Apache2.4 -f C:\\Program Files\\Apache2.4\\conf\\httpd.conf -d C:\\Program Files\\Apache2.4\\.' 
[Wed Jun 14 21:42:51.757538 2017] [mpm_winnt:notice] [pid 7988:tid 696] AH00418: Parent: Created child process 8692 
[Wed Jun 14 21:42:51.973446 2017] [mpm_winnt:notice] [pid 8692:tid 636] AH00354: Child: Starting 64 worker threads. 
[Wed Jun 14 21:59:11.710766 2017] [mpm_winnt:notice] [pid 7988:tid 696] AH00422: Parent: Received shutdown signal -- Shutting down the server. 
[Wed Jun 14 21:59:13.712698 2017] [mpm_winnt:notice] [pid 8692:tid 636] AH00364: Child: All worker threads have exited. 
[Wed Jun 14 21:59:13.731009 2017] [mpm_winnt:notice] [pid 7988:tid 696] AH00430: Parent: Child process exited successfully. 
[Wed Jun 14 23:12:16.868389 2017] [mpm_winnt:notice] [pid 7988:tid 692] AH00455: Apache/2.4.2 (Win64) configured -- resuming normal operations 
[Wed Jun 14 23:12:16.869389 2017] [mpm_winnt:notice] [pid 7988:tid 692] AH00456: Server built: May 11 2012 20:42:30 
[Wed Jun 14 23:12:16.869389 2017] [core:notice] [pid 7988:tid 692] AH00094: Command line: 'C:\\Program Files\\Apache2.4\\bin\\httpd.exe -d C:/Program Files/Apache2.4 -f C:\\Program Files\\Apache2.4\\conf\\httpd.conf -d C:\\Program Files\\Apache2.4\\.' 
[Wed Jun 14 23:12:16.870391 2017] [mpm_winnt:notice] [pid 7988:tid 692] AH00418: Parent: Created child process 7152 
[Wed Jun 14 23:12:17.107601 2017] [mpm_winnt:notice] [pid 7152:tid 616] AH00354: Child: Starting 64 worker threads. 
[Wed Jun 14 23:12:24.939591 2017] [mpm_winnt:notice] [pid 7988:tid 692] AH00422: Parent: Received shutdown signal -- Shutting down the server. 
[Wed Jun 14 23:12:26.941397 2017] [mpm_winnt:notice] [pid 7152:tid 616] AH00364: Child: All worker threads have exited. 
[Wed Jun 14 23:12:26.960081 2017] [mpm_winnt:notice] [pid 7988:tid 692] AH00430: Parent: Child process exited successfully. 

wsgi.py:

import os, sys 
sys.path.append('C:/Program Files/Apache2.4/htdocs/RMS/RMS') 
sys.path.append('C:/Program Files/Apache2.4/htdocs/RMS') 

os.environ.setdefault["DJANGO_SETTINGS_MODULE"] = "RMS.settings" 

import django.core.handlers.wsgi 
application = django.core.handlers.wsgi.WSGIHandlers() 

的httpd-vhosts.conf

<VirtualHost *:8080> 
    WSGIScriptAlias /rms 'C:/Program Files/Apache2.4/htdocs/RMS/RMS/wsgi.py' 
    Alias /media/ 'C:/Program Files/Apache2.4/htdocs/RMS/media' 
    Alias /media/ 'C:/Program Files/Apache2.4/htdocs/RMS/media' 

    <Directory "C:/Program Files/Apache2.4/htdocs/RMS/static"> 
    <Files wsgi.py> 
    Order allow, deny 
    Allow from all 
    </Files> 
    </Directory> 

    <Directory "C:/Program Files/Apache2.4/htdocs/RMS/media"> 
    Order allow, deny 
    Allow from all 
    </Directory> 
</VirtualHost> 

的httpd.conf

Listen 8080 
LoadModule wsgi_module modules/mod_wsgi.so 
# Virtual hosts 
Include conf/extra/httpd-vhosts.conf 
+0

你可以包含你的conf文件和wsgi文件的內容嗎? – Tom

+0

你好!我用我所做的所有設置更新了我的帖子。我需要說''httpd.conf'文件太大了。我只添加我編輯的部分。你能說什麼?也許我使用了錯誤的'mod_wsgi'文件? –

+0

我從這個網站使用'mod_wsgi':http://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi你能爲我提供一些建議嗎? –

回答

0

Graham Dumpleton提到的是,對我的工作方式方法,我很幸運地碰到過這樣的項目:modwgsi Google Group再次格雷厄姆。

  1. 安裝使用PIP(最好爲virtualenv中)
  2. 運行mod_wsgi-express module-config獲得的設置複製到httpd.conf文件mod_wsgi,我選擇了複製這些上面的LoadModules名單。

不要移動並重新命名.pyd文件,不要管它。要進行測試,創建helloworld.wsgi具有以下內容:

def application(environ, start_response): 
status = '200 OK' 
output = b'Hello World!' 

response_headers = [('Content-type', 'text/plain'), 
        ('Content-Length', str(len(output)))] 
start_response(status, response_headers) 

return [output] 

在你的虛擬主機,創建一個指向創建WSGI文件,例如WSGIScriptAlias WSGIScriptAlias /test C:/wsgitest/helloworld.wsgi