2

I'm having issues running django and apache2/mod_wsgi. This is my current setup:

Ubuntu: 16.0
Apache: 2.4.18
Python: 3.5
Django: 1.10

I have installed a virtualenv inside my django project for user 'carma'. Structure is:

/home/carma/mycarma
|- manage.py
static
mycarma
    |__init__.py
    |settings.py
    |urls.py
    |wsgi.py
mycarmanev
    bin
    include
    lib

This is the content of /etc/apache2/sites-available/000-default.conf

<VirtualHost *:80>
    Alias /static /home/carma/mycarma/static
    <Directory /home/carma/mycarma/static>
            Require all granted
    </Directory>
    <Directory /home/carma/mycarma/mycarma>
            <Files wsgi.py>
                    Require all granted
            </Files>
    </Directory>

    WSGIDaemonProcess mycarma python-path=/home/carma/mycarma/ python-home=/home/carma/mycarma/mycarmavirtuale$
    WSGIProcessGroup mycarma
    WSGIScriptAlias / /home/carma/mycarma/mycarma/wsgi.py

This is the content of wsgi.py

import os,sys
from django.core.wsgi import get_wsgi_application
DJANGO_PATH =  os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')
sys.path.append(DJANGO_PATH)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mycarma.settings")

application = get_wsgi_application()

And I have already given permissions:

sudo chown -R www-data:www-data /home/carma/mycarma/mycarmaenv
sudo chown -R www-data:www-data /home/carma/mycarma

The problem comes when I try to access the url of my server, checking the apache log this is the issue:

[wsgi:error] [pid 25183] mod_wsgi (pid=25183): Target WSGI script '/home/carma/mycarma/mycarma/wsgi.py' cannot be loaded as Python module.
[wsgi:error] [pid 25183] mod_wsgi (pid=25183): Exception occurred processing WSGI script '/home/carma/mycarma/mycarma/wsgi.py'.
[wsgi:error] [pid 25183] Traceback (most recent call last):
[wsgi:error] [pid 25183] File "/home/carma/mycarma/mycarma/wsgi.py", line 12, in <module>
[wsgi:error] [pid 25183] from django.core.wsgi import get_wsgi_application
[wsgi:error] [pid 25183] ImportError: No module named 'django'

I have read all the possible discussions here and outside, found also this thread which expose exactly the same problem but nothing worked for me.

Any help is appreciated thanks!

Community
  • 1
  • 1
Fabio
  • 129
  • 1
  • 7

1 Answers1

3

I think it is a typo, mycarmanev or mycarmavirtuanev ?

WSGIDaemonProcess mycarma python-path=/home/carma/mycarma/ python-home=/home/carma/mycarma/myprojectenv
Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134
itzMEonTV
  • 19,851
  • 4
  • 39
  • 49