django - Apache Django 内部服务器错误 (Ubuntu 18.04)
问题描述
我有一个 Django wagtail 应用程序。我可以在调试中运行它,也可以在 django 服务器上运行它,但是如果我尝试使用 Apache2 WSGI 在我的 Ubuntu 18.04 服务器上运行它,我会收到“内部服务器错误”。阿帕奇日志:
[Mon Jan 18 23:29:23.673557 2021] [mpm_event:notice] [pid 92324:tid 140613127453760] AH00491: caught SIGTERM, shutting down
Exception ignored in: <function BaseEventLoop.__del__ at 0x7fe301c1fc10>
Traceback (most recent call last):
File "/usr/lib/python3.8/asyncio/base_events.py", line 654, in __del__
NameError: name 'ResourceWarning' is not defined
Exception ignored in: <function Local.__del__ at 0x7fe301b95040>
Traceback (most recent call last):
File "/home/user/wow/lib/python3.8/site-packages/asgiref/local.py", line 96, in __del__
NameError: name 'TypeError' is not defined
Exception ignored in: <function Local.__del__ at 0x7fe301b95040>
Traceback (most recent call last):
File "/home/user/wow/lib/python3.8/site-packages/asgiref/local.py", line 96, in __del__
NameError: name 'TypeError' is not defined
Exception ignored in: <function Local.__del__ at 0x7fe301b95040>
Traceback (most recent call last):
File "/home/user/wow/lib/python3.8/site-packages/asgiref/local.py", line 96, in __del__
NameError: name 'TypeError' is not defined
[Mon Jan 18 23:29:24.194636 2021] [mpm_event:notice] [pid 92749:tid 139932982541376] AH00489: Apache/2.4.41 (Ubuntu) OpenSSL/1.1.1f mod_wsgi/4.6.8 Python/3.8 configured -- resuming normal operations
[Mon Jan 18 23:29:24.194764 2021] [core:notice] [pid 92749:tid 139932982541376] AH00094: Command line: '/usr/sbin/apache2'
[Mon Jan 18 23:29:31.468972 2021] [wsgi:error] [pid 92750:tid 139932932445952] WSGI without exception
我的 wsgi 文件:
import os
import time
import traceback
import signal
import sys
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "americanss.settings.production")
application = get_wsgi_application()
try:
application = get_wsgi_application()
print('WSGI without exception')
except Exception:
print('handing WSGI exception')
# Error loading applications
if 'mod_wsgi' in sys.modules:
traceback.print_exc()
os.kill(os.getpid(), signal.SIGINT)
time.sleep(2.5)
根据我的发现,引发的异常发生了,似乎没有人知道为什么,但大多数时候它并没有阻止应用程序运行。在我的情况下,我收到一个 500 错误,我无法判断这是否与回溯有关,因为没有其他人报告带有这些错误的 500。
apactctl -M:
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 143.110.226.199. Set the 'ServerName' directive globally to suppress this message
Loaded Modules:
core_module (static)
so_module (static)
watchdog_module (static)
http_module (static)
log_config_module (static)
logio_module (static)
version_module (static)
unixd_module (static)
access_compat_module (shared)
alias_module (shared)
auth_basic_module (shared)
authn_core_module (shared)
authn_file_module (shared)
authz_core_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
deflate_module (shared)
dir_module (shared)
env_module (shared)
filter_module (shared)
mime_module (shared)
mpm_event_module (shared)
negotiation_module (shared)
reqtimeout_module (shared)
rewrite_module (shared)
setenvif_module (shared)
socache_shmcb_module (shared)
ssl_module (shared)
status_module (shared)
wsgi_module (shared)
解决方案
推荐阅读
- linux - Make install 在终端命令中成功,但在 shell 脚本中失败
- java - 获取 java.lang.OutOfMemoryError:Jboss 上的 java 堆空间
- flutter - Flutter - 类'QuerySnapshot'没有实例方法'document'
- ios - 数组对象的过滤字典
- csv - 将空格分隔的文本文件加载到 MariaDB 数据库表中
- wpf - 我应该在哪个窗口中实例化我的对象?
- ios - 如何在iOS中根据时间更改获取访问位置权限值?
- flutter - Flutter:如何在没有 mp3 扩展的情况下流式传输由 http url 提供的实时音频
- javascript - 单击重叠区域时如何触发两个元素的单击
- go - 返回消息列表