ошибка импорта нет модуля django в apache wsgi.py - PullRequest
0 голосов
/ 18 июня 2020
• 1000 . Я подозреваю, что это как-то связано с моим wsgidaemon в моем файле conf, поэтому я также включил его. Я подозреваю, что у него проблемы с моей виртуальной средой. Я думаю, что правильно настроил его с помощью python -home, но, возможно, я ошибаюсь. моя виртуальная среда расположена по адресу /home/bitnami/geodjangobackend1/venv, а мой файл wsgi.py - по адресу /home/bitnami/geodjangobackend1/kapany/kapany/apache/wsgi.py. Любая помощь приветствуется, и, пожалуйста, дайте мне знать, могу ли я предоставить дополнительную информацию. Это моя первая установка apache, и хотя я видел это сообщение об ошибке, я попытался выполнить шаги, указанные в этих вопросах, и не смог его исправить. Спасибо

error.log

[Thu Jun 18 05:22:11.574684 2020] [wsgi:error] [pid 5485:tid 140428143658752] [remote 195.54.160.135:39416] mod_wsgi (pid=5485): Target WSGI script '/home/bitnami/geodjang
obackend1/kapany/kapany/apache/wsgi.py' cannot be loaded as Python module.
[Thu Jun 18 05:22:11.574759 2020] [wsgi:error] [pid 5485:tid 140428143658752] [remote 195.54.160.135:39416] mod_wsgi (pid=5485): Exception occurred processing WSGI script 
'/home/bitnami/geodjangobackend1/kapany/kapany/apache/wsgi.py'.
[Thu Jun 18 05:22:11.574845 2020] [wsgi:error] [pid 5485:tid 140428143658752] [remote 195.54.160.135:39416] Traceback (most recent call last):
[Thu Jun 18 05:22:11.574865 2020] [wsgi:error] [pid 5485:tid 140428143658752] [remote 195.54.160.135:39416]   File "/home/bitnami/geodjangobackend1/kapany/kapany/apache/ws
gi.py", line 26, in <module>
[Thu Jun 18 05:22:11.574869 2020] [wsgi:error] [pid 5485:tid 140428143658752] [remote 195.54.160.135:39416]     from django.core.wsgi import get_wsgi_application
[Thu Jun 18 05:22:11.574885 2020] [wsgi:error] [pid 5485:tid 140428143658752] [remote 195.54.160.135:39416] ImportError: No module named 'django'

wsgi.py

import os, sys

# Calculate the path based on the location of the WSGI script.

apache_configuration= os.path.dirname(__file__)

project = os.path.dirname(apache_configuration)

workspace = os.path.dirname(project)

sys.path.append(workspace)

sys.path.append(project)


# Add the path to 3rd party django application and to django itself.

sys.path.append('/home/bitnami')

#os.environ['DJANGO_SETTINGS_MODULE'] = 'kapany.apache.override'

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'kapany.apache.override')

from django.core.wsgi import get_wsgi_application

application = get_wsgi_application()

000-default.conf

<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName 34.210.84.14

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf

WSGIDaemonProcess kapany python-path=/home/bitnami/geodjangobackend1 python-home=/home/bitnami/geodjangobackend1/venv

WSGIProcessGroup kapany

WSGIScriptAlias / /home/bitnami/geodjangobackend1/kapany/kapany/apache/wsgi.py

<Directory "/home/bitnami/geodjangobackend1/kapany/kapany/apache/">
Require all granted
</Directory>
</VirtualHost>
...