我正在尝试部署django服务器,但我什至重新安装了所有服务器,但是在apache中遇到了相同的错误,并且我不知道如何使它正常工作,希望您能为我提供帮助,因为它会使我发疯。
Wsgi已正确安装,可以通过runserver命令正常运行,但不能与apache一起运行。
httpd.conf
LoadFile "c:/users/srvpc/appdata/local/programs/python/python35/python35.dll"
LoadModule wsgi_module "c:/users/srvpc/appdata/local/programs/python/python35/lib/site-packages/mod_wsgi/server/mod_wsgi.cp35-win_amd64.pyd"
WSGIPythonHome "c:/users/srvpc/appdata/local/programs/python/python35"
WSGIScriptAlias / "C:\abaa\proyecto\proyecto\wsgi.py"
WSGIPythonPath "C:\abaa\proyecto"
<Directory "C:\abaa\proyecto">
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /static "C:\abaa\proyecto\aplicacion\static"
<Directory "C:\abaa\proyecto\aplicacion\static">
Require all granted
</Directory>
apache访问日志:
192.168.1.216 - - [18/Feb/2019:10:57:58 -0600] "GET / HTTP/1.1" 500 530
apache错误日志:
AH00558: httpd.exe: Could not reliably determine the server's fully qualified domain name, using fe80::c109:4f13:c7f3:c19b. Set the 'ServerName' directive globally to suppress this message
[Mon Feb 18 10:57:53.985985 2019] [mpm_winnt:notice] [pid 1800:tid 540] AH00455: Apache/2.4.38 (Win64) mod_wsgi/4.5.24 Python/3.5 configured -- resuming normal operations
[Mon Feb 18 10:57:53.985985 2019] [mpm_winnt:notice] [pid 1800:tid 540] AH00456: Apache Lounge VC15 Server built: Jan 18 2019 14:26:34
[Mon Feb 18 10:57:53.985985 2019] [core:notice] [pid 1800:tid 540] AH00094: Command line: 'C:\\Apache24\\bin\\httpd.exe -d C:/Apache24'
[Mon Feb 18 10:57:53.985985 2019] [mpm_winnt:notice] [pid 1800:tid 540] AH00418: Parent: Created child process 1824
AH00558: httpd.exe: Could not reliably determine the server's fully qualified domain name, using fe80::c109:4f13:c7f3:c19b. Set the 'ServerName' directive globally to suppress this message
AH00558: httpd.exe: Could not reliably determine the server's fully qualified domain name, using fe80::c109:4f13:c7f3:c19b. Set the 'ServerName' directive globally to suppress this message
[Mon Feb 18 10:57:54.236011 2019] [mpm_winnt:notice] [pid 1824:tid 556] AH00354: Child: Starting 64 worker threads.
[Mon Feb 18 10:57:59.017764 2019] [wsgi:error] [pid 1824:tid 1108] [client 192.168.1.216:49423] mod_wsgi (pid=1824): Target WSGI script 'C:/abaa/proyecto/proyecto/wsgi.py' cannot be loaded as Python module.
[Mon Feb 18 10:57:59.017764 2019] [wsgi:error] [pid 1824:tid 1108] [client 192.168.1.216:49423] mod_wsgi (pid=1824): Exception occurred processing WSGI script 'C:/abaa/proyecto/proyecto/wsgi.py'.
[Mon Feb 18 10:57:59.017764 2019] [wsgi:error] [pid 1824:tid 1108] [client 192.168.1.216:49423] Traceback (most recent call last):\r
[Mon Feb 18 10:57:59.017764 2019] [wsgi:error] [pid 1824:tid 1108] [client 192.168.1.216:49423] File "C:/abaa/proyecto/proyecto/wsgi.py", line 12, in <module>\r
[Mon Feb 18 10:57:59.017764 2019] [wsgi:error] [pid 1824:tid 1108] [client 192.168.1.216:49423] from django.core.wsgi import get_wsgi_application\r
[Mon Feb 18 10:57:59.017764 2019] [wsgi:error] [pid 1824:tid 1108] [client 192.168.1.216:49423] ImportError: No module named 'django'\r
答案 0 :(得分:0)
WSGIPythonHome
应该不是系统Python安装目录,而是虚拟环境路径(例如,您可以找到{{1 }},Lib
等,并且在Scripts
内可以找到Lib\site-packages
)。
更改此:
django
收件人:
WSGIPythonHome "c:/users/srvpc/appdata/local/programs/python/python35"
当然,假设您的虚拟环境位于WSGIPythonHome "c:/users/srvpc/Envs/yourenv"
中。