有人可以帮助我说出什么问题吗?
我需要使用Django + Apache
.
当我尝试启动Apache时,它向我显示错误:The requested operation has failed.
我试图将Listen 80
更改为不同的值,但没有帮助。在将下一个设置添加到文件后也会出现此错误httpd.conf
(没有这些设置,Apache 开始正常(:
LoadModule wsgi_module modules/mod_wsgi.so
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
我使用:
1( 阿帕奇 2.4 (x64(
2( 蟒蛇 3.5.2 (x64(
3( 姜戈 1.10.5
4( mod_wsgi-4.5.15+AP24VC14-CP35-CP35M-win_amd64.whl
5( 视窗 8.1 (x64(
也许我用错了mod_wsgi
?我从存档中取出mod_wsgi.cp35-win_amd64.pyd
文件mod_wsgi‑4.5.15+ap24vc14‑cp35‑cp35m‑win_amd64.whl
并将该文件重命名为mod_wsgi.so
。之后,将该文件放入Apache的模块文件夹中。
错误.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
Graham Dumpleton 提到的方法是对我有用的方法,我很幸运地遇到了这个项目:Graham 再次的 modwgsi Google Group。
- 使用 pip 安装
mod_wsgi
(最好是虚拟环境( - 运行
mod_wsgi-express module-config
以获取要复制到httpd.conf
文件中的设置,我选择将这些设置复制到 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