在 Apache 上托管 Django 应用程序

hosting Django application on Apache

提问人:Waly 提问时间:4/5/2020 更新时间:1/14/2021 访问量:56

问:

我正在阅读有关在 Apache 上托管 Django 应用程序的教程,并且我对这些类型的服务器错误不熟悉。

我修改了 apache 配置文件,以使用以下代码与应用程序的 wsgi 进行通信:

LoadModule wsgi_module "c:/users/adwy/appdata/local/programs/python/python35/lib/site-packages/mod_wsgi/server/mod_wsgi.cp35-win_amd64.pyd"
WSGIScriptAlias / "D:/Backup/Learning Python/Organized and important file/Learning files and sheets/Django_ Learning_ 1/weblog_app/weblog_app/wsgi.py"
WSGIPythonHome "C:/Users/Adwy/AppData/Local/Programs/Python/Python35"
WSGIPythonPath "D:/Backup/Learning Python/Organized and important file/Learning files and sheets/Django_ Learning_ 1/weblog_app/weblog_app"

Alias /static/ C:/Users/Adwy/Adwy/Django_ Learning_ 1/Lib/site-packages/django/contrib/admin\static

Alias /templates/ C:/Users/Adwy/Adwy/Django_ Learning_ 1/Lib/site-packages/django/contrib/admin/templates

<Directory C:/Users/Adwy/Adwy/Django_ Learning_ 1/Lib/site-packages/django/contrib/admin/static>
    Require all granted
</Directory>

<Directory C:/Users/Adwy/Adwy/Django_ Learning_ 1/Lib/site-packages/django/contrib/admin/templates>
    Require all granted
</Directory>

<Directory "D:/Backup/Learning Python/Organized and important file/Learning files and sheets/Django_ Learning_ 1/weblog_app/weblog_app">
   <Files wsgi.py>
      Require all granted
   </Files>
</Directory>

-- 现在我重新启动了我的 apache 服务器,并并行运行 Django 服务器,我收到错误 500,

在这里,我从Apache服务器复制了以下错误日志:

[Sat Apr 04 18:41:05.681919 2020] [wsgi:warn] [pid 8608:tid 288] (70008)Partial results are valid but processing is incomplete: mod_wsgi (pid=8608): Unable to stat Python home C:/Users/Adwy/AppData/Local/Programs/Python/Python35. Python interpreter may not be able to be initialized correctly. Verify the supplied path and access permissions for whole of the path.
 [Sat Apr 04 18:41:05.725921 2020] [mpm_winnt:notice] [pid 8608:tid 288] AH00354: Child: Starting 150 worker threads.
[Sat Apr 04 18:41:05.780924 2020] [wsgi:error] [pid 8608:tid 1780] [client 192.168.2.130:49438] mod_wsgi (pid=8608): Failed to exec Python script file 'D:/Backup/Learning Python/Organized and important file/Learning files and sheets/Django_ Learning_ 1/weblog_app/weblog_app/wsgi.py'.
[Sat Apr 04 18:41:05.780924 2020] [wsgi:error] [pid 8608:tid 1780] [client 192.168.2.130:49438] mod_wsgi (pid=8608): Exception occurred processing WSGI script 'D:/Backup/Learning Python/Organized and important file/Learning files and sheets/Django_ Learning_ 1/weblog_app/weblog_app/wsgi.py'.
[Sat Apr 04 18:41:05.780924 2020] [wsgi:error] [pid 8608:tid 1780] [client 192.168.2.130:49438] Traceback (most recent call last):\r
[Sat Apr 04 18:41:05.780924 2020] [wsgi:error] [pid 8608:tid 1780] [client 192.168.2.130:49438]   File "D:/Backup/Learning Python/Organized and important file/Learning files and sheets/Django_ Learning_ 1/weblog_app/weblog_app/wsgi.py", line 12, in <module>\r
[Sat Apr 04 18:41:05.780924 2020] [wsgi:error] [pid 8608:tid 1780] [client 192.168.2.130:49438]     from django.core.wsgi import get_wsgi_application\r
[Sat Apr 04 18:41:05.780924 2020] [wsgi:error] [pid 8608:tid 1780] [client 192.168.2.130:49438] ImportError: No module named 'django'\r
[Sat Apr 04 18:41:05.781924 2020] [wsgi:error] [pid 8608:tid 1772] [client 192.168.2.130:49439] mod_wsgi (pid=8608): Failed to exec Python script file 'D:/Backup/Learning Python/Organized and important file/Learning files and sheets/Django_ Learning_ 1/weblog_app/weblog_app/wsgi.py'.
[Sat Apr 04 18:41:05.781924 2020] [wsgi:error] [pid 8608:tid 1772] [client 192.168.2.130:49439] mod_wsgi (pid=8608): Exception occurred processing WSGI script 'D:/Backup/Learning Python/Organized and important file/Learning files and sheets/Django_ Learning_ 1/weblog_app/weblog_app/wsgi.py'.
[Sat Apr 04 18:41:05.781924 2020] [wsgi:error] [pid 8608:tid 1772] [client 192.168.2.130:49439] Traceback (most recent call last):\r
[Sat Apr 04 18:41:05.781924 2020] [wsgi:error] [pid 8608:tid 1772] [client 192.168.2.130:49439]   File "D:/Backup/Learning Python/Organized and important file/Learning files and sheets/Django_ Learning_ 1/weblog_app/weblog_app/wsgi.py", line 12, in <module>\r
[Sat Apr 04 18:41:05.781924 2020] [wsgi:error] [pid 8608:tid 1772] [client 192.168.2.130:49439]     from django.core.wsgi import get_wsgi_application\r
[Sat Apr 04 18:41:05.781924 2020] [wsgi:error] [pid 8608:tid 1772] [client 192.168.2.130:49439] ImportError: No module named 'django'\r
[Sat Apr 04 18:41:05.818927 2020] [wsgi:error] [pid 8608:tid 1772] [client 192.168.2.130:49441] mod_wsgi (pid=8608): Failed to exec Python script file 'D:/Backup/Learning Python/Organized and important file/Learning files and sheets/Django_ Learning_ 1/weblog_app/weblog_app/wsgi.py'., referer: http://192.168.2.130/
[Sat Apr 04 18:41:05.818927 2020] [wsgi:error] [pid 8608:tid 1772] [client 192.168.2.130:49441] mod_wsgi (pid=8608): Exception occurred processing WSGI script 'D:/Backup/Learning Python/Organized and important file/Learning files and sheets/Django_ Learning_ 1/weblog_app/weblog_app/wsgi.py'., referer: http://192.168.2.130/
[Sat Apr 04 18:41:05.818927 2020] [wsgi:error] [pid 8608:tid 1772] [client 192.168.2.130:49441] Traceback (most recent call last):\r, referer: http://192.168.2.130/
[Sat Apr 04 18:41:05.818927 2020] [wsgi:error] [pid 8608:tid 1772] [client 192.168.2.130:49441]   File "D:/Backup/Learning Python/Organized and important file/Learning files and sheets/Django_ Learning_ 1/weblog_app/weblog_app/wsgi.py", line 12, in <module>\r, referer: http://192.168.2.130/
[Sat Apr 04 18:41:05.818927 2020] [wsgi:error] [pid 8608:tid 1772] [client 192.168.2.130:49441]     from django.core.wsgi import get_wsgi_application\r, referer: http://192.168.2.130/
[Sat Apr 04 18:41:05.818927 2020] [wsgi:error] [pid 8608:tid 1772] [client 192.168.2.130:49441] ImportError: No module named 'django'\r, referer: http://192.168.2.130/

服务器错误的主要信息是:

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.

我希望我能让这个服务器运行,

谢谢

python django apache

评论

0赞 David Teather 4/5/2020
运行 django 的 python 环境没有安装 django。尝试运行 pip install django
0赞 Waly 4/5/2020
谢谢David,我重新安装了Django,并重新启动了一切。但是,我仍然遇到同样的错误!- 我真的不明白问题出在哪里
0赞 Waly 4/5/2020
我认为这里服务器的日志中有一个重大且重复的wsgiError,但我无法找出问题所在

答: 暂无答案