【发布时间】:2019-05-12 03:04:12
【问题描述】:
我正在尝试通过 mod_wsgi WSGIDaemon 方法将我的 django 项目的虚拟主机部署到 apache2 中,我使用的是 ubuntu 16.04,但出现以下错误。
来自 apache2 错误日志:
[2018 年 12 月 11 日星期二 11:55:31.748517] [wsgi:error] [pid 14231:tid 139821891782400] [remote ::1:44748] mod_wsgi (pid=14231): Target WSGI script '/var/www/ html/rasa_django/rasa_django/wsgi.py' 不能作为 Python 模块加载。 [2018 年 12 月 11 日星期二 11:55:31.748570] [wsgi:error] [pid 14231:tid 139821891782400] [remote ::1:44748] mod_wsgi (pid=14231): 处理 WSGI 脚本'/var/www/html 时发生异常/rasa_django/rasa_django/wsgi.py'。 [2018 年 12 月 11 日星期二 11:55:31.748639] [wsgi:error] [pid 14231:tid 139821891782400] [remote ::1:44748] Traceback(最近一次通话最后): [2018 年 12 月 11 日星期二 11:55:31.748657] [wsgi:error] [pid 14231:tid 139821891782400] [远程 ::1:44748] 文件“/var/www/html/rasa_django/rasa_django/wsgi.py”,行12、在 [2018 年 12 月 11 日星期二 11:55:31.748662] [wsgi:error] [pid 14231:tid 139821891782400] [remote ::1:44748] from django.core.wsgi import get_wsgi_application [2018 年 12 月 11 日星期二 11:55:31.748677] [wsgi:error] [pid 14231:tid 139821891782400] [remote ::1:44748] ImportError: No module named 'django' [2018 年 12 月 11 日星期二 11:55:31.787336] [wsgi:error] [pid 14231:tid 139821849777920] [remote ::1:38604] mod_wsgi (pid=14231): Target WSGI script '/var/www/html/rasa_django /rasa_django/wsgi.py' 不能作为 Python 模块加载。 [2018 年 12 月 11 日星期二 11:55:31.787379] [wsgi:error] [pid 14231:tid 139821849777920] [remote ::1:38604] mod_wsgi (pid=14231): 处理 WSGI 脚本'/var/www/html 时发生异常/rasa_django/rasa_django/wsgi.py'。 [2018 年 12 月 11 日星期二 11:55:31.787447] [wsgi:error] [pid 14231:tid 139821849777920] [remote ::1:38604] Traceback(最近一次通话最后): [2018 年 12 月 11 日星期二 11:55:31.787465] [wsgi:error] [pid 14231:tid 139821849777920] [远程 ::1:38604] 文件“/var/www/html/rasa_django/rasa_django/wsgi.py”,行12、在 [2018 年 12 月 11 日星期二 11:55:31.787470] [wsgi:error] [pid 14231:tid 139821849777920] [remote ::1:38604] from django.core.wsgi import get_wsgi_application [2018 年 12 月 11 日星期二 11:55:31.787484] [wsgi:error] [pid 14231:tid 139821849777920] [remote ::1:38604] ImportError: No module named 'django'
在我的主机文件 000-default.conf 中:
服务器名称 www.rasa_django.com DocumentRoot /var/www/html/rasa_django 错误日志 /var/www/logs/error.log CustomLog /var/www/logs/custom.log 合并
Alias /static /var/www/html/rasa_django/static
<Directory /var/www/html/rasa_django/static>
Require all granted
</Directory>
<Directory /var/www/html/rasa_django/rasa_django>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess rasa_django.com python-path=/var/www/html/rasa_django python-home=/home/aarbor_01/env_site1/lib/python3.6/site-packages
WSGIProcessGroup rasa_django.com
WSGIScriptAlias / /var/www/html/rasa_django/rasa_django/wsgi.py
这是我的 wsgi.py 文件:
导入操作系统
从 django.core.wsgi 导入 get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'rasa_django.settings')
应用程序 = get_wsgi_application()
【问题讨论】:
标签: django apache ubuntu mod-wsgi