Use mod_wsgi on ubuntu

I cannot for the life of me get apache2 and mod_wsgi to work on my django project.

I have a virtualhost with directives setup like this with python-home pointing to my venv:

WSGIDaemonProcess dianarice_art processes=2 threads=12 python-home=/usr/local/virtualenvs/dianarice_venv python-path=/var/www/webapps/ dianarice:/var/www/webapps/dianarice/dianarice:/usr/local/virtualenvs/dianarice_venv/lib/python3.6/site-packages
WSGIScriptAlias / /var/www/webapps/dianarice/dianarice/wsgi.py

I'm getting this error:

ModuleNotFoundError: No module named 'django'

I have it installed in the venv

This is how I installed mod_wsgi

sudo apt-get install libapache2-mod-wsgi-py3

Any help would be appreciated. I am trying to move my webfaction sites to linode ubuntu.

2 Replies

If you installed django through pip then it may be that the directory django is installed in isn't included in the virtualenv configuration. As an alternative, try installing django with:

python -m pip install django

Aside from that, there's a StackOverflow thread here with suggestions on how to fix common configuration problems with mod_wsgi:

https://stackoverflow.com/questions/38756969/apache-with-virtualenv-and-mod-wsgi-importerror-no-module-named-django

Thank you. It appears my virtualenv was not installing correctly. It's very confusing using pip inside venv. I also inadvertently installed mod_wsgi 2 instead of 3. I had multiple issues that I finally ironed out.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct