[Thu Jun 16 20:32:08.505090 2022] [wsgi:error] [pid 131476:tid 140411386394368] [remote 193.32.127.157:53433] Traceback (most recent call last):
[Thu Jun 16 20:32:08.505133 2022] [wsgi:error] [pid 131476:tid 140411386394368] [remote 193.32.127.157:53433] File "/root/novo-ai-api-main/backend/server/server/wsgi.py", line 18, in <module>
[Thu Jun 16 20:32:08.505139 2022] [wsgi:error] [pid 131476:tid 140411386394368] [remote 193.32.127.157:53433] from django.core.wsgi import get_wsgi_application
[Thu Jun 16 20:32:08.505159 2022] [wsgi:error] [pid 131476:tid 140411386394368] [remote 193.32.127.157:53433] ModuleNotFoundError: No module named 'django.core'
[Thu Jun 16 20:48:58.603180 2022] [wsgi:error] [pid 131476:tid 140411361216256] [remote 200.110.48.158:35204] mod_wsgi (pid=131476): Failed to exec Python script file '/root/novo-ai-api-main/backend/server/server/wsgi.py'.
[Thu Jun 16 20:48:58.603316 2022] [wsgi:error] [pid 131476:tid 140411361216256] [remote 200.110.48.158:35204] mod_wsgi (pid=131476): Exception occurred processing WSGI script '/root/novo-ai-api-main/backend/server/server/wsgi.py'.
[Thu Jun 16 20:48:58.603447 2022] [wsgi:error] [pid 131476:tid 140411361216256] [remote 200.110.48.158:35204] Traceback (most recent call last):
[Thu Jun 16 20:48:58.603477 2022] [wsgi:error] [pid 131476:tid 140411361216256] [remote 200.110.48.158:35204] File "/root/novo-ai-api-main/backend/server/server/wsgi.py", line 18, in <module>
[Thu Jun 16 20:48:58.603483 2022] [wsgi:error] [pid 131476:tid 140411361216256] [remote 200.110.48.158:35204] from django.core.wsgi import get_wsgi_application
[Thu Jun 16 20:48:58.603506 2022] [wsgi:error] [pid 131476:tid 140411361216256] [remote 200.110.48.158:35204] ModuleNotFoundError: No module named 'django.core'这些是我所有的工作文件
**#000-default.conf**
<VirtualHost *:80>
#ServerAdmin webmaster@localhost
DocumentRoot /root/novo-ai-api-main
ErrorLog /root/novo-ai-api-main/error.log
CustomLog /root/novo-ai-api-main/access.log combine
<Directory /root/novo-ai-api-main/backend/server/server>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /static /root/novo-ai-api-main/static
<Directory /root/novo-ai-api-main/static>
Require all granted
</Directory>
WSGIScriptAlias / /root/novo-ai-api-main/backend/server/server/wsgi.py
WSGIDaemonProcess django_app python-path=/root/novo-ai-api-main/backend/server python-home=/root/novo-ai-api-main/backend/django/
WSGIProcessGroup django_app
</VirtualHost>
#apache2.conf
**apache2.conf**
'''
<pre>
ServerRoot "/etc/apache2"
Timeout 300
MaxKeepAliveRequests 100
#KeepAliveTimeout: Number of seconds to wait for the next request from the
#same client on the same connection.
#
KeepAliveTimeout 5
#These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
LogLevel warn
#Sets the default security model of the Apache2 HTTPD server. It does
<Directory />
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<Directory /var/www/>
AllowOverride All
Require all granted
</Directory>
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
#AccessFileName .htaccess
#<FilesMatch "^\.ht">
#Require all denied
#</FilesMatch>
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
#vim: syntax=apache ts=4 sw=4 sts=4 sr noet
</pre>
'''我为python3.8正确地安装了mod_wsgi
**#wsgi.py**
import os, sys
import site
site.addsitedir('/root/novo-ai-api-main/django/lib/python3.8/site-packages')
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')
application = get_wsgi_application()权限
而且,我已经给了所有工作文件的权限,但是什么都没有发生。
06年6月16日22:05。
drwxr-xr-x 19 root root 4096 Jun 14 14:05 ..
drwxr-xr-x 3 root root 4096 Jun 13 23:38 .local
drwxrwxr-x 8 root root 4096 Jun 16 01:24 mod_wsgi-4.9.2
drwxr-xr-x 5 www-data www-data 4096 Jun 14 23:53 novo-ai-api-main <-(project)
drwxr-xr-x 5 www-data www-data 4096 Jun 14 23:14 backend
drw-r--r-- 8 www-data www-data 4096 Jun 14 00:33 static
drwxr-xr-x 6 www-data www-data 4096 Jun 14 00:16 django <- (venv) ####我试过所有的方法,但都解决不了这个问题。请尽快帮我一把
发布于 2022-06-18 07:44:24
在您的wsgi.py中,尝试先导入Django (import django),然后在行os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')之后添加:
django.setup()
查看有关此这里的文档
此外,您还需要更改导入顺序,以便在完成此操作后导入get_wsgi_application。
https://stackoverflow.com/questions/72652400
复制相似问题