我在Windows 2012 R2服务器计算机上使用Apache 2.4和python 3.4以及相应版本的mod_wsgi。全部64位。在启动apache之后,我遇到了这个问题:
内部服务器错误
服务器遇到内部错误或配置错误 无法完成您的请求。
请通过admin@example.com与服务器管理员联系以告知 它们发生此错误的时间以及您执行的操作 就在这个错误之前。
有关此错误的详细信息可能在服务器错误中可用 日志中。
因此,在查看错误日志时,我找到了相关的行(以调试模式登录):
The 'Apache2.4' service is restarting.
[Wed Oct 05 12:06:08.561983 2016] [mpm_winnt:notice] [pid 7756:tid 528] AH00424: Parent: Received restart signal -- Restarting the server.
[Wed Oct 05 12:06:08.561983 2016] [mpm_winnt:debug] [pid 10092:tid 456] child.c(1157): AH00357: Child: Exit event signaled. Child process is ending.
[Wed Oct 05 12:06:08.561983 2016] [mpm_winnt:debug] [pid 10092:tid 1000] child.c(735): AH00348: Child: Accept thread exiting.
[Wed Oct 05 12:06:08.561983 2016] [mpm_winnt:debug] [pid 10092:tid 996] child.c(735): AH00348: Child: Accept thread exiting.
[Wed Oct 05 12:06:08.577609 2016] [wsgi:warn] [pid 7756:tid 528] mod_wsgi: Compiled for Python/3.4.2.
[Wed Oct 05 12:06:08.577609 2016] [wsgi:warn] [pid 7756:tid 528] mod_wsgi: Runtime using Python/3.4.3.
[Wed Oct 05 12:06:08.577609 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
[Wed Oct 05 12:06:08.577609 2016] [mpm_winnt:notice] [pid 7756:tid 528] AH00456: Apache Lounge VC10 Server built: Jul 9 2016 11:59:00
[Wed Oct 05 12:06:08.577609 2016] [core:notice] [pid 7756:tid 528] AH00094: Command line: 'C:\\Apache24\\bin\\httpd.exe -d C:/Apache24'
[Wed Oct 05 12:06:08.577609 2016] [core:debug] [pid 7756:tid 528] log.c(1543): AH02639: Using SO_REUSEPORT: no (0)
[Wed Oct 05 12:06:08.577609 2016] [mpm_winnt:notice] [pid 7756:tid 528] AH00418: Parent: Created child process 10576
[Wed Oct 05 12:06:08.577609 2016] [mpm_winnt:debug] [pid 7756:tid 528] mpm_winnt.c(429): AH00402: Parent: Sent the scoreboard to the child
[Wed Oct 05 12:06:08.905752 2016] [wsgi:warn] [pid 10576:tid 456] mod_wsgi: Compiled for Python/3.4.2.
[Wed Oct 05 12:06:08.905752 2016] [wsgi:warn] [pid 10576:tid 456] mod_wsgi: Runtime using Python/3.4.3.
[Wed Oct 05 12:06:08.905752 2016] [mpm_winnt:debug] [pid 10576:tid 456] mpm_winnt.c(1718): AH00453: Child process is running
[Wed Oct 05 12:06:08.905752 2016] [wsgi:info] [pid 10576:tid 456] mod_wsgi (pid=10576): Initializing Python.
[Wed Oct 05 12:06:08.952607 2016] [wsgi:info] [pid 10576:tid 456] mod_wsgi (pid=10576): Attach interpreter ''.
[Wed Oct 05 12:06:08.952607 2016] [wsgi:info] [pid 10576:tid 456] mod_wsgi (pid=10576): Adding '\xe2\x80\x9cC:/Apache24/htdocs/EquipmentCalibration\xe2\x80\x9d' to path.
[Wed Oct 05 12:06:08.952607 2016] [mpm_winnt:debug] [pid 10576:tid 456] mpm_winnt.c(343): AH00391: Child: Retrieved our scoreboard from the parent.
[Wed Oct 05 12:06:08.952607 2016] [mpm_winnt:debug] [pid 10576:tid 456] mpm_winnt.c(465): AH00403: Child: Waiting for data for listening socket 0.0.0.0:8090
[Wed Oct 05 12:06:08.952607 2016] [mpm_winnt:debug] [pid 7756:tid 528] mpm_winnt.c(512): AH00408: Parent: Duplicating socket 500 (0.0.0.0:8090) and sending it to child process 10576
[Wed Oct 05 12:06:08.952607 2016] [mpm_winnt:debug] [pid 7756:tid 528] mpm_winnt.c(512): AH00408: Parent: Duplicating socket 540 ([::]:8090) and sending it to child process 10576
[Wed Oct 05 12:06:08.952607 2016] [mpm_winnt:debug] [pid 7756:tid 528] mpm_winnt.c(531): AH00411: Parent: Sent 2 listeners to child 10576
[Wed Oct 05 12:06:08.952607 2016] [mpm_winnt:debug] [pid 10576:tid 456] mpm_winnt.c(465): AH00403: Child: Waiting for data for listening socket [::]:8090
[Wed Oct 05 12:06:08.952607 2016] [mpm_winnt:debug] [pid 10576:tid 456] mpm_winnt.c(490): AH00407: Child: retrieved 2 listeners from parent
[Wed Oct 05 12:06:09.577635 2016] [mpm_winnt:debug] [pid 10092:tid 456] child.c(1214): AH00359: Child: Released the start mutex
[Wed Oct 05 12:06:09.577635 2016] [mpm_winnt:debug] [pid 10576:tid 456] child.c(1020): AH00352: Child: Acquired the start mutex.
[Wed Oct 05 12:06:09.577635 2016] [mpm_winnt:debug] [pid 10092:tid 456] child.c(1226): AH00361: Child: 64 threads blocked on the completion port
[Wed Oct 05 12:06:09.577635 2016] [mpm_winnt:notice] [pid 10576:tid 456] AH00354: Child: Starting 64 worker threads.
[Wed Oct 05 12:06:09.577635 2016] [mpm_winnt:debug] [pid 10576:tid 872] child.c(399): AH00334: Child: Accept thread listening on 0.0.0.0:8090 using AcceptFilter data
[Wed Oct 05 12:06:09.577635 2016] [mpm_winnt:debug] [pid 10576:tid 876] child.c(399): AH00334: Child: Accept thread listening on [::]:8090 using AcceptFilter data
[Wed Oct 05 12:06:10.581491 2016] [mpm_winnt:notice] [pid 10092:tid 456] AH00364: Child: All worker threads have exited.
[Wed Oct 05 12:06:10.581491 2016] [wsgi:info] [pid 10092:tid 456] mod_wsgi (pid=10092): Destroying interpreters.
[Wed Oct 05 12:06:10.581491 2016] [wsgi:info] [pid 10092:tid 456] mod_wsgi (pid=10092): Destroy interpreter 'PCTEST-IIS.pctestlab.com:8090|'.
[Wed Oct 05 12:06:10.581491 2016] [wsgi:info] [pid 10092:tid 456] mod_wsgi (pid=10092): End interpreter 'PCTEST-IIS.pctestlab.com:8090|'.
[Wed Oct 05 12:06:10.612772 2016] [wsgi:info] [pid 10092:tid 456] mod_wsgi (pid=10092): Cleanup interpreter ''.
[Wed Oct 05 12:06:10.644022 2016] [wsgi:info] [pid 10092:tid 456] mod_wsgi (pid=10092): Terminating Python.
[Wed Oct 05 12:06:10.659650 2016] [wsgi:info] [pid 10092:tid 456] mod_wsgi (pid=10092): Python has shutdown.
[Wed Oct 05 12:06:10.659650 2016] [mpm_winnt:debug] [pid 10092:tid 456] mpm_winnt.c(1723): AH00454: Child process is exiting
[Wed Oct 05 12:06:13.971571 2016] [authz_core:debug] [pid 10576:tid 1116] mod_authz_core.c(806): [client ::1:61169] AH01626: authorization result of Require all granted: granted
[Wed Oct 05 12:06:13.971571 2016] [authz_core:debug] [pid 10576:tid 1116] mod_authz_core.c(806): [client ::1:61169] AH01626: authorization result of <RequireAny>: granted
[Wed Oct 05 12:06:13.971571 2016] [authz_core:debug] [pid 10576:tid 1116] mod_authz_core.c(806): [client ::1:61169] AH01626: authorization result of Require all granted: granted
[Wed Oct 05 12:06:13.971571 2016] [authz_core:debug] [pid 10576:tid 1116] mod_authz_core.c(806): [client ::1:61169] AH01626: authorization result of <RequireAny>: granted
[Wed Oct 05 12:06:14.019608 2016] [wsgi:info] [pid 10576:tid 1116] mod_wsgi (pid=10576): Create interpreter 'PCTEST-IIS.pctestlab.com:8090|'.
[Wed Oct 05 12:06:14.050609 2016] [wsgi:info] [pid 10576:tid 1116] mod_wsgi (pid=10576): Adding '\xe2\x80\x9cC:/Apache24/htdocs/EquipmentCalibration\xe2\x80\x9d' to path.
[Wed Oct 05 12:06:14.053609 2016] [wsgi:info] [pid 10576:tid 1116] [client ::1:61169] mod_wsgi (pid=10576, process='', application='PCTEST-IIS.pctestlab.com:8090|'): Loading WSGI script 'C:/EquipmentCalibration/equipcal/wsgi.py'.
[Wed Oct 05 12:06:14.660623 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] mod_wsgi (pid=10576): Target WSGI script 'C:/EquipmentCalibration/equipcal/wsgi.py' cannot be loaded as Python module.
[Wed Oct 05 12:06:14.660623 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] mod_wsgi (pid=10576): Exception occurred processing WSGI script 'C:/EquipmentCalibration/equipcal/wsgi.py'.
[Wed Oct 05 12:06:14.660623 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] Traceback (most recent call last):\r
[Wed Oct 05 12:06:14.661628 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "C:/EquipmentCalibration/equipcal/wsgi.py", line 16, in <module>\r
[Wed Oct 05 12:06:14.661628 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] application = get_wsgi_application()\r
[Wed Oct 05 12:06:14.661628 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "C:\\Python34\\lib\\site-packages\\django\\core\\wsgi.py", line 13, in get_wsgi_application\r
[Wed Oct 05 12:06:14.661628 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] django.setup(set_prefix=False)\r
[Wed Oct 05 12:06:14.661628 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "C:\\Python34\\lib\\site-packages\\django\\__init__.py", line 22, in setup\r
[Wed Oct 05 12:06:14.661628 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)\r
[Wed Oct 05 12:06:14.662625 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 53, in __getattr__\r
[Wed Oct 05 12:06:14.662625 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] self._setup(name)\r
[Wed Oct 05 12:06:14.662625 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 41, in _setup\r
[Wed Oct 05 12:06:14.662625 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] self._wrapped = Settings(settings_module)\r
[Wed Oct 05 12:06:14.662625 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 97, in __init__\r
[Wed Oct 05 12:06:14.662625 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] mod = importlib.import_module(self.SETTINGS_MODULE)\r
[Wed Oct 05 12:06:14.663602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "C:\\Python34\\Lib\\importlib\\__init__.py", line 109, in import_module\r
[Wed Oct 05 12:06:14.663602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] return _bootstrap._gcd_import(name[level:], package, level)\r
[Wed Oct 05 12:06:14.663602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "<frozen importlib._bootstrap>", line 2254, in _gcd_import\r
[Wed Oct 05 12:06:14.663602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "<frozen importlib._bootstrap>", line 2237, in _find_and_load\r
[Wed Oct 05 12:06:14.663602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "<frozen importlib._bootstrap>", line 2212, in _find_and_load_unlocked\r
[Wed Oct 05 12:06:14.663602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed\r
[Wed Oct 05 12:06:14.663602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "<frozen importlib._bootstrap>", line 2254, in _gcd_import\r
[Wed Oct 05 12:06:14.663602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "<frozen importlib._bootstrap>", line 2237, in _find_and_load\r
[Wed Oct 05 12:06:14.663602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked\r
[Wed Oct 05 12:06:14.663602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] ImportError: No module named 'equipcal'\r
[Wed Oct 05 12:06:14.678602 2016] [authz_core:debug] [pid 10576:tid 1116] mod_authz_core.c(806): [client ::1:61170] AH01626: authorization result of Require all granted: granted, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.678602 2016] [authz_core:debug] [pid 10576:tid 1116] mod_authz_core.c(806): [client ::1:61170] AH01626: authorization result of <RequireAny>: granted, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.679602 2016] [authz_core:debug] [pid 10576:tid 1116] mod_authz_core.c(806): [client ::1:61170] AH01626: authorization result of Require all granted: granted, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.679602 2016] [authz_core:debug] [pid 10576:tid 1116] mod_authz_core.c(806): [client ::1:61170] AH01626: authorization result of <RequireAny>: granted, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.679602 2016] [wsgi:info] [pid 10576:tid 1116] [client ::1:61170] mod_wsgi (pid=10576, process='', application='PCTEST-IIS.pctestlab.com:8090|'): Loading WSGI script 'C:/EquipmentCalibration/equipcal/wsgi.py'., referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.681602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] mod_wsgi (pid=10576): Target WSGI script 'C:/EquipmentCalibration/equipcal/wsgi.py' cannot be loaded as Python module., referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.681602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] mod_wsgi (pid=10576): Exception occurred processing WSGI script 'C:/EquipmentCalibration/equipcal/wsgi.py'., referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.682602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] Traceback (most recent call last):\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.682602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "C:/EquipmentCalibration/equipcal/wsgi.py", line 16, in <module>\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.682602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] application = get_wsgi_application()\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.682602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "C:\\Python34\\lib\\site-packages\\django\\core\\wsgi.py", line 13, in get_wsgi_application\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.682602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] django.setup(set_prefix=False)\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.682602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "C:\\Python34\\lib\\site-packages\\django\\__init__.py", line 22, in setup\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.682602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.682602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 53, in __getattr__\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.682602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] self._setup(name)\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 41, in _setup\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] self._wrapped = Settings(settings_module)\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 97, in __init__\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] mod = importlib.import_module(self.SETTINGS_MODULE)\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "C:\\Python34\\Lib\\importlib\\__init__.py", line 109, in import_module\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] return _bootstrap._gcd_import(name[level:], package, level)\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "<frozen importlib._bootstrap>", line 2254, in _gcd_import\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "<frozen importlib._bootstrap>", line 2237, in _find_and_load\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "<frozen importlib._bootstrap>", line 2212, in _find_and_load_unlocked\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "<frozen importlib._bootstrap>", line 2254, in _gcd_import\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "<frozen importlib._bootstrap>", line 2237, in _find_and_load\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] ImportError: No module named 'equipcal'\r, referer: http://localhost:8090/calbase/static
显然问题是这样的:
Target WSGI script 'C:/EquipmentCalibration/equipcal/wsgi.py' cannot be loaded as Python module.
和
ImportError: No module named 'equipcal'\r,
凡equipcal是我的项目名称。
但这看起来很奇怪,wsgi怎么可能没有加载为python而我的proejct无法识别?特别是我试图将项目目录添加到wsgi中。我的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/
"""
from django.core.wsgi import get_wsgi_application
import os, sys
sys.path.append('C:\Apache24\htdocs\EquipmentCalibration\equipcal')
sys.path.append('C:\Apache24\htdocs\EquipmentCalibration')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "equipcal.settings")
application = get_wsgi_application()
在httpd.conf中:
DocumentRoot "c:/Apache24/htdocs"
# 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>
我的项目位于c:/ Apache24 / htdocs / EquipmentCalibration,项目名为equipcal。
有了帮助,我发现了其他大多数问题,但却真的陷入了困境。有人可以帮帮我吗?
我需要像wsgi_handler.py这样的东西吗?