skip to Main Content

I’m try to deploy virtual host my django project into apache2 via mod_wsgi WSGIDaemon method, i’m using ubuntu 16.04 and i’m getting following error.

From apache2 error log:

[Tue Dec 11 11:55:31.748517 2018] [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’ cannot be loaded as Python module.
[Tue Dec 11 11:55:31.748570 2018] [wsgi:error] [pid 14231:tid 139821891782400] [remote ::1:44748] mod_wsgi (pid=14231): Exception occurred processing WSGI script ‘/var/www/html/rasa_django/rasa_django/wsgi.py’.
[Tue Dec 11 11:55:31.748639 2018] [wsgi:error] [pid 14231:tid 139821891782400] [remote ::1:44748] Traceback (most recent call last):
[Tue Dec 11 11:55:31.748657 2018] [wsgi:error] [pid 14231:tid 139821891782400] [remote ::1:44748] File “/var/www/html/rasa_django/rasa_django/wsgi.py”, line 12, in
[Tue Dec 11 11:55:31.748662 2018] [wsgi:error] [pid 14231:tid 139821891782400] [remote ::1:44748] from django.core.wsgi import get_wsgi_application
[Tue Dec 11 11:55:31.748677 2018] [wsgi:error] [pid 14231:tid 139821891782400] [remote ::1:44748] ImportError: No module named ‘django’
[Tue Dec 11 11:55:31.787336 2018] [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’ cannot be loaded as Python module.
[Tue Dec 11 11:55:31.787379 2018] [wsgi:error] [pid 14231:tid 139821849777920] [remote ::1:38604] mod_wsgi (pid=14231): Exception occurred processing WSGI script ‘/var/www/html/rasa_django/rasa_django/wsgi.py’.
[Tue Dec 11 11:55:31.787447 2018] [wsgi:error] [pid 14231:tid 139821849777920] [remote ::1:38604] Traceback (most recent call last):
[Tue Dec 11 11:55:31.787465 2018] [wsgi:error] [pid 14231:tid 139821849777920] [remote ::1:38604] File “/var/www/html/rasa_django/rasa_django/wsgi.py”, line 12, in
[Tue Dec 11 11:55:31.787470 2018] [wsgi:error] [pid 14231:tid 139821849777920] [remote ::1:38604] from django.core.wsgi import get_wsgi_application
[Tue Dec 11 11:55:31.787484 2018] [wsgi:error] [pid 14231:tid 139821849777920] [remote ::1:38604] ImportError: No module named ‘django’

In my host file 000-default.conf:

ServerName www.rasa_django.com
DocumentRoot /var/www/html/rasa_django
ErrorLog /var/www/logs/error.log
CustomLog /var/www/logs/custom.log combined

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

Here my wsgi.py file:

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault(‘DJANGO_SETTINGS_MODULE’, ‘rasa_django.settings’)

application = get_wsgi_application()

2

Answers


  1. Chosen as BEST ANSWER

    I'm cleared the issue by folling link https://github.com/GrahamDumpleton/mod_wsgi/issues/378


  2. According to the docs, if you’re using a virtual environment (which I’m assuming env_site1 is), then you should point python-home to the root of that environment.

    Try:

    WSGIDaemonProcess rasa_django.com python-path=/var/www/html/rasa_django python-home=/home/aarbor_01/env_site1
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search