Django在Apache2上部署时出现未指定错误



下面是我尝试在Debian 11服务器上部署Django==3.2.12,wagtail==2.16.1,python 3.8.2,mod_wsgi 4.9时的错误。我在末尾有一个完整的堆栈跟踪。

class SimpleLazyObject(LazyObject):
TypeError: Error when calling the metaclass bases
'property' object is not callable

当我在我的本地开发机器(Mac(上运行这个程序时,它运行得很好。我发现有人也有同样的问题,但不清楚是如何解决的。

我一直在使用的资源是1,2,3,4。我尝试过使用pip和从源代码安装mod_wsgi。为Apache2配置使用了各种指南。从python 3.8升级到3.9,并降级到3.7。

Create interpreter '0.0.0.0|'.
[Tue Mar 29 11:49:06.679710 2022] [wsgi:info] [pid 199764:tid 139683953432320] mod_wsgi (pid=199764): Adding '/var/www/html/portal' to path.
[Tue Mar 29 11:49:06.680057 2022] [wsgi:info] [pid 199764:tid 139683953432320] mod_wsgi (pid=199764): Adding  '/var/www/html/portal/portalvenv/lib/python3.8/site-packages' to path.
[Tue Mar 29 11:49:06.689628 2022] [wsgi:info] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] mod_wsgi (pid=199764, process='saida-befree_portal', application='0.0.0.0|'): Loading Python script file '/var/www/html/portal/portal/wsgi.py'.
[Tue Mar 29 11:49:06.705081 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] mod_wsgi (pid=199764): Failed to exec Python script file '/var/www/html/portal/portal/wsgi.py'.
[Tue Mar 29 11:49:06.713633 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] mod_wsgi (pid=199764): Exception occurred processing WSGI script '/var/www/html/portal/portal/wsgi.py'.
[Tue Mar 29 11:49:06.713903 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] Traceback (most recent call last):
[Tue Mar 29 11:49:06.714017 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy]   File "/var/www/html/portal/portal/wsgi.py", line 12, in <module>
[Tue Mar 29 11:49:06.714210 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy]     from django.core.wsgi import get_wsgi_application
[Tue Mar 29 11:49:06.714304 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy]   File "/var/www/html/portal/portalvenv/lib/python3.8/site-packages/django/__init__.py", line 1, in <module>
[Tue Mar 29 11:49:06.717663 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy]     from django.utils.version import get_version
[Tue Mar 29 11:49:06.717837 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy]   File "/var/www/html/portal/portalvenv/lib/python3.8/site-packages/django/utils/version.py", line 7, in <module>
[Tue Mar 29 11:49:06.718002 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy]     from django.utils.regex_helper import _lazy_re_compile
[Tue Mar 29 11:49:06.718072 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy]   File "/var/www/html/portal/portalvenv/lib/python3.8/site-packages/django/utils/regex_helper.py", line 10, in <module>
[Tue Mar 29 11:49:06.718305 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy]     from django.utils.functional import SimpleLazyObject
[Tue Mar 29 11:49:06.720700 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy]   File "/var/www/html/portal/portalvenv/lib/python3.8/site-packages/django/utils/functional.py", line 362, in <module>
[Tue Mar 29 11:49:06.721066 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy]     class SimpleLazyObject(LazyObject):
[Tue Mar 29 11:49:06.721539 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] TypeError: Error when calling the metaclass bases
[Tue Mar 29 11:49:06.721610 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy]     'property' object is not callable
[Tue Mar 29 11:49:58.057546 2022] [reqtimeout:info] [pid 199765:tid 139683870795520] [client xx.xx.xx.xxx:yyyy] AH01382: Request header read timeout

我遇到了同样的问题,所以我做了以下步骤:

使用以下命令删除apache2库-sudo apt-get删除python pip apache2 libapache2 mod wsgi

然后使用以下命令安装正确的库-sudo apt-get安装python3 pip apache2 libapache2-mod-wsgi-py3

这解决了我的错误。

最新更新