带有mod_wsgi的Apache 2.4:wsgi.py

时间:2016-09-30 01:25:08

标签: django apache mod-wsgi wsgi

我正在尝试在Windows服务器上部署我的django项目,使用带有mod_wsgi和pythong 3.4的apache 2.4。

现在,当我可以运行apache就好了但是在转到localhost时出现了内部服务器错误,我有这个内部服务器错误。然后我查看了error.log并找到了以下内容:

The 'Apache2.4' service is restarting.
The 'Apache2.4' service has restarted.
winnt:notice] [pid 7756:tid 528] AH00424: Parent: Received restart signal -- Restarting the server.
[Thu Sep 29 18:18:19.003503 2016] [wsgi:warn] [pid 7756:tid 528] mod_wsgi: Compiled for Python/3.4.2.
[Thu Sep 29 18:18:19.003503 2016] [wsgi:warn] [pid 7756:tid 528] mod_wsgi: Runtime using Python/3.4.3.
[Thu Sep 29 18:18:19.003503 2016] [mpm_winnt:notice] [pid 7756:tid 528] AH00455: Apache/2.4.23 (Win64) mod_wsgi/4.4.12 Python/3.4.3 configured -- resuming normal operations
[Thu Sep 29 18:18:19.003503 2016] [mpm_winnt:notice] [pid 7756:tid 528] AH00456: Apache Lounge VC10 Server built: Jul  9 2016 11:59:00
[Thu Sep 29 18:18:19.003503 2016] [core:notice] [pid 7756:tid 528] AH00094: Command line: 'C:\\Apache24\\bin\\httpd.exe -d C:/Apache24'
[Thu Sep 29 18:18:19.003503 2016] [mpm_winnt:notice] [pid 7756:tid 528] AH00418: Parent: Created child process 10400
[Thu Sep 29 18:18:19.347246 2016] [wsgi:warn] [pid 10400:tid 456] mod_wsgi: Compiled for Python/3.4.2.
[Thu Sep 29 18:18:19.347246 2016] [wsgi:warn] [pid 10400:tid 456] mod_wsgi: Runtime using Python/3.4.3.
[Thu Sep 29 18:18:19.987923 2016] [mpm_winnt:notice] [pid 10400:tid 456] AH00354: Child: Starting 64 worker threads.
[Thu Sep 29 18:18:21.003576 2016] [mpm_winnt:notice] [pid 7476:tid 460] AH00364: Child: All worker threads have exited.
[Thu Sep 29 18:18:27.175151 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] mod_wsgi (pid=10400): Target WSGI script 'C:/EquipmentCalibration/equipcal/wsgi.py' cannot be loaded as Python module.
[Thu Sep 29 18:18:27.175151 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] mod_wsgi (pid=10400): Exception occurred processing WSGI script 'C:/EquipmentCalibration/equipcal/wsgi.py'.
[Thu Sep 29 18:18:27.175151 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] Traceback (most recent call last):\r
[Thu Sep 29 18:18:27.175151 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759]   File "C:/EquipmentCalibration/equipcal/wsgi.py", line 16, in <module>\r
[Thu Sep 29 18:18:27.175151 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759]     application = get_wsgi_application()\r
[Thu Sep 29 18:18:27.176153 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759]   File "C:\\Python34\\lib\\site-packages\\django\\core\\wsgi.py", line 13, in get_wsgi_application\r
[Thu Sep 29 18:18:27.176153 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759]     django.setup(set_prefix=False)\r
[Thu Sep 29 18:18:27.177153 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759]   File "C:\\Python34\\lib\\site-packages\\django\\__init__.py", line 22, in setup\r
[Thu Sep 29 18:18:27.177153 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759]     configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)\r
[Thu Sep 29 18:18:27.177153 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759]   File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 53, in __getattr__\r
[Thu Sep 29 18:18:27.177153 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759]     self._setup(name)\r
[Thu Sep 29 18:18:27.178128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759]   File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 41, in _setup\r
[Thu Sep 29 18:18:27.178128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759]     self._wrapped = Settings(settings_module)\r
[Thu Sep 29 18:18:27.178128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759]   File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 97, in __init__\r
[Thu Sep 29 18:18:27.178128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759]     mod = importlib.import_module(self.SETTINGS_MODULE)\r
[Thu Sep 29 18:18:27.178128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759]   File "C:\\Python34\\Lib\\importlib\\__init__.py", line 109, in import_module\r
[Thu Sep 29 18:18:27.178128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759]     return _bootstrap._gcd_import(name[level:], package, level)\r
[Thu Sep 29 18:18:27.178128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759]   File "<frozen importlib._bootstrap>", line 2254, in _gcd_import\r
[Thu Sep 29 18:18:27.178128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759]   File "<frozen importlib._bootstrap>", line 2237, in _find_and_load\r
[Thu Sep 29 18:18:27.179154 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759]   File "<frozen importlib._bootstrap>", line 2212, in _find_and_load_unlocked\r
[Thu Sep 29 18:18:27.179154 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759]   File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed\r
[Thu Sep 29 18:18:27.179154 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759]   File "<frozen importlib._bootstrap>", line 2254, in _gcd_import\r
[Thu Sep 29 18:18:27.179154 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759]   File "<frozen importlib._bootstrap>", line 2237, in _find_and_load\r
[Thu Sep 29 18:18:27.179154 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759]   File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked\r
[Thu Sep 29 18:18:27.179154 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] ImportError: No module named 'equipcal'\r
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] mod_wsgi (pid=10400): Target WSGI script 'C:/EquipmentCalibration/equipcal/wsgi.py' cannot be loaded as Python module., referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] mod_wsgi (pid=10400): Exception occurred processing WSGI script 'C:/EquipmentCalibration/equipcal/wsgi.py'., referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] Traceback (most recent call last):\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760]   File "C:/EquipmentCalibration/equipcal/wsgi.py", line 16, in <module>\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760]     application = get_wsgi_application()\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760]   File "C:\\Python34\\lib\\site-packages\\django\\core\\wsgi.py", line 13, in get_wsgi_application\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760]     django.setup(set_prefix=False)\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760]   File "C:\\Python34\\lib\\site-packages\\django\\__init__.py", line 22, in setup\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760]     configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.200129 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760]   File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 53, in __getattr__\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.200129 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760]     self._setup(name)\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.200129 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760]   File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 41, in _setup\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.200129 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760]     self._wrapped = Settings(settings_module)\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.200129 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760]   File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 97, in __init__\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.200129 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760]     mod = importlib.import_module(self.SETTINGS_MODULE)\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760]   File "C:\\Python34\\Lib\\importlib\\__init__.py", line 109, in import_module\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760]     return _bootstrap._gcd_import(name[level:], package, level)\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760]   File "<frozen importlib._bootstrap>", line 2254, in _gcd_import\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760]   File "<frozen importlib._bootstrap>", line 2237, in _find_and_load\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760]   File "<frozen importlib._bootstrap>", line 2212, in _find_and_load_unlocked\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760]   File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760]   File "<frozen importlib._bootstrap>", line 2254, in _gcd_import\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760]   File "<frozen importlib._bootstrap>", line 2237, in _find_and_load\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760]   File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] ImportError: No module named 'equipcal'\r, referer: http://localhost:8090/calbase

显然它在我的项目中调用了我的wsgi.py问题。目前我只使用startproject时创建的默认wsgi.py文件。所以就是这样:

"""
WSGI config for equipcal project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "equipcal.settings")

application = get_wsgi_application()

我目前的https.conf是这样的:

# Change Python path used by the server.
WSGIPythonPath “/EquipmentCalibration”

# Make calls to http://localhost/ refer to the Python/WSGI-script located at the specified location.
WSGIScriptAlias / /EquipmentCalibration/equipcal/wsgi.py

# Make calls to http://localhost/static refer to the specified folder.
Alias /static/ /EquipmentCalibration/static

Alias /media/ /EquipmentCalibration/media

<Directory /EquipmentCalibration/static>
Require all granted
</Directory>

<Directory /EquipmentCalibration/media>
Require all granted
</Directory>

<Directory /EquipmentCalibration/equipcal>
<Files wsgi.py>
Require all granted
</Files>
</Directory>

我试着做一些研究,但似乎没有找到我应该如何配置它。请问有人可以对此有所了解吗?

0 个答案:

没有答案