提问人:rornfldla 提问时间:11/13/2023 更新时间:11/13/2023 访问量:15
Django 未连接到 Apache 服务器
Django not connected to the Apache server
问:
当我尝试将 Django 与 Apache 2.4 匹配时,出现了此错误。 但是当我访问服务器时,我收到 500 个错误 我还没有解决这个错误
错误代码
[Mon Nov 13 20:44:10.540478 2023] [wsgi:error] [pid 16020:tid 1112] [client ::1:51548] mod_wsgi (pid=16020): Failed to exec Python script file 'C:/Apache24/htdocs/django_file/ranking/ranking/wsgi.py'.
[Mon Nov 13 20:44:10.540478 2023] [wsgi:error] [pid 16020:tid 1112] [client ::1:51548] mod_wsgi (pid=16020): Exception occurred processing WSGI script 'C:/Apache24/htdocs/django_file/ranking/ranking/wsgi.py'.
[Mon Nov 13 20:44:10.540478 2023] [wsgi:error] [pid 16020:tid 1112] [client ::1:51548] Traceback (most recent call last):\r
[Mon Nov 13 20:44:10.540478 2023] [wsgi:error] [pid 16020:tid 1112] [client ::1:51548] File "C:/Apache24/htdocs/django_file/ranking/ranking/wsgi.py", line 19, in <module>\r
[Mon Nov 13 20:44:10.540478 2023] [wsgi:error] [pid 16020:tid 1112] [client ::1:51548] application = get_wsgi_application()\r
[Mon Nov 13 20:44:10.540478 2023] [wsgi:error] [pid 16020:tid 1112] [client ::1:51548] ^^^^^^^^^^^^^^^^^^^^^^\r
[Mon Nov 13 20:44:10.540478 2023] [wsgi:error] [pid 16020:tid 1112] [client ::1:51548] File "C:\\Users\\dkdle\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\django\\core\\wsgi.py", line 12, in get_wsgi_application\r
[Mon Nov 13 20:44:10.540478 2023] [wsgi:error] [pid 16020:tid 1112] [client ::1:51548] django.setup(set_prefix=False)\r
[Mon Nov 13 20:44:10.540478 2023] [wsgi:error] [pid 16020:tid 1112] [client ::1:51548] File "C:\\Users\\dkdle\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\django\\__init__.py", line 19, in setup\r
[Mon Nov 13 20:44:10.540478 2023] [wsgi:error] [pid 16020:tid 1112] [client ::1:51548] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)\r
[Mon Nov 13 20:44:10.540478 2023] [wsgi:error] [pid 16020:tid 1112] [client ::1:51548] ^^^^^^^^^^^^^^^^^^^^^^^\r
[Mon Nov 13 20:44:10.540478 2023] [wsgi:error] [pid 16020:tid 1112] [client ::1:51548] File "C:\\Users\\dkdle\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\django\\conf\\__init__.py", line 102, in __getattr__\r
[Mon Nov 13 20:44:10.540478 2023] [wsgi:error] [pid 16020:tid 1112] [client ::1:51548] self._setup(name)\r
[Mon Nov 13 20:44:10.540478 2023] [wsgi:error] [pid 16020:tid 1112] [client ::1:51548] File "C:\\Users\\dkdle\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\django\\conf\\__init__.py", line 89, in _setup\r
[Mon Nov 13 20:44:10.540478 2023] [wsgi:error] [pid 16020:tid 1112] [client ::1:51548] self._wrapped = Settings(settings_module)\r
[Mon Nov 13 20:44:10.540478 2023] [wsgi:error] [pid 16020:tid 1112] [client ::1:51548] ^^^^^^^^^^^^^^^^^^^^^^^^^\r
[Mon Nov 13 20:44:10.540478 2023] [wsgi:error] [pid 16020:tid 1112] [client ::1:51548] File "C:\\Users\\dkdle\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\django\\conf\\__init__.py", line 217, in __init__\r
[Mon Nov 13 20:44:10.540478 2023] [wsgi:error] [pid 16020:tid 1112] [client ::1:51548] mod = importlib.import_module(self.SETTINGS_MODULE)\r
[Mon Nov 13 20:44:10.540478 2023] [wsgi:error] [pid 16020:tid 1112] [client ::1:51548] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r
[Mon Nov 13 20:44:10.540478 2023] [wsgi:error] [pid 16020:tid 1112] [client ::1:51548] File "C:\\Users\\dkdle\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\importlib\\__init__.py", line 126, in import_module\r
[Mon Nov 13 20:44:10.540478 2023] [wsgi:error] [pid 16020:tid 1112] [client ::1:51548] return _bootstrap._gcd_import(name[level:], package, level)\r
[Mon Nov 13 20:44:10.540478 2023] [wsgi:error] [pid 16020:tid 1112] [client ::1:51548] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r
[Mon Nov 13 20:44:10.540478 2023] [wsgi:error] [pid 16020:tid 1112] [client ::1:51548] File "<frozen importlib._bootstrap>", line 1204, in _gcd_import\r
[Mon Nov 13 20:44:10.540478 2023] [wsgi:error] [pid 16020:tid 1112] [client ::1:51548] File "<frozen importlib._bootstrap>", line 1176, in _find_and_load\r
[Mon Nov 13 20:44:10.540478 2023] [wsgi:error] [pid 16020:tid 1112] [client ::1:51548] File "<frozen importlib._bootstrap>", line 1135, in _find_and_load_unlocked\r
[Mon Nov 13 20:44:10.540478 2023] [wsgi:error] [pid 16020:tid 1112] [client ::1:51548] ModuleNotFoundError: No module named 'ranking.settings'; 'ranking' is not a package\r
Python 3.11.5版本 窗户 11
我有这个虚拟主机
<VirtualHost *:80>
ServerName my server domain
WSGIScriptAlias / "C:/Apache24/htdocs/django_file/ranking/ranking/wsgi.py"
WSGIPassAuthorization On
<Directory "C:/Apache24/htdocs/django_file/ranking/ranking">
Options +ExecCGI
AddHandler wsgi-script .py
Require all granted
</Directory>
</VirtualHost>
Django wsgi.py 代码
import os
import sys
sys.path.append('/path/to/ranking/module')
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ranking.settings')
application = get_wsgi_application()
答: 暂无答案
评论
WSGIPythonPath