2

I am attempting to get a website to load within a web browser using Django + mod_wsgi and apache. I have exactly the same problem as in This Question Here, but the solution found there does not work in my case.

Here is my httpd-vhosts.conf setup:

WSGIDaemonProcess binshellpress.com python-home=/usr/local/docs/binshellpress-production/virtpy/ python-path=/usr/local/docs/binshellpress-production/virtpy/lib/python3.6/
WSGIProcessGroup binshellpress.com
WSGIApplicationGroup %{GLOBAL}

<VirtualHost *:80>
  ServerAdmin [email protected]
  DocumentRoot "/usr/local/docs/binshellpress-production/root"
  ServerName binshellpress.com
  ServerAlias www.binshellpress.com
  ErrorLog "/var/log/httpd/bsp-error_log"
  CustomLog "/var/log/httpd/bsp-access_log" common

  Alias /robots.txt /usr/local/docs/binshellpress-production/static/robots.txt
  Alias /favicon.ico /usr/local/docs/binshellpress-production/static/favicon.ico

  Alias /media/ /usr/local/docs/binshellpress-production/media
  Alias /static/ /usr/local/docs/binshellpress-production/static

  <Directory /usr/local/docs/binshellpress-production/static>
    Require all granted
  </Directory>

  <Directory /usr/local/docs/binshellpress-production/media>
    Require all granted
  </Directory>

  WSGIScriptAlias / /usr/local/docs/binshellpress-production/binshellpress/wsgi.py process-group=binshellpress.com

  <Directory /usr/local/docs/binshellpress-production/binshellpress>
    <Files wsgi.py>
      Require all granted
    </Files>
  </Directory>
</Virtualhost>

I have a virtual environment set up at /usr/local/docs/binshellpress-production/virtpy. I have rebuilt mod_wsgi to explicitly use that virtual environment. I have performed the permissions modifications as described in the answer to This Question

No change.

I am desperate. I have been searching up and down. I can't figure out what to do. Please, help me. I beg you.

Thank you, for anything, thank, just please, help me, thank you.

2
  • On the server, as the user Apache runs as, have you tried activating the virtualenv and executing python manage.py runserver? That'll often expose the underlying issue. It's always best to compile mod_wsgi with a system-wide install of Python, not one in a virtualenv, but it must be the same version you build the virtualenv against. Commented Oct 15, 2017 at 22:19
  • It isn't strictly necessary to compile mod_wsgi against a system Python even if using a virtual environment. In fact when you run pip install mod_wsgi in a virtual environment, it has no choice. Commented Oct 16, 2017 at 0:21

1 Answer 1

1

First off, check the value of python-home is correct by running command line Python you want to use and do:

import sys
sys.prefix

It should be the same value.

Also be aware that:

python-path=/usr/local/docs/binshellpress-production/virtpy/lib/python3.6/

shouldn't be needed and I can't see why you would add that.

Next, run the check in:

What libraries and locations is mod_wsgi linked against?

If your mod_wsgi binary is definitely compiled against the correct Python version, the only other issue it could be is that it is a non standard Python installation and not a system Python. If this is the case and it isn't linked correctly, it may be finding the system Python shared library instead of that for your separate Python installation.

Again from the command line for Python from the virtual environment, try:

import sys
sys.real_prefix

What do you get for that?

Sign up to request clarification or add additional context in comments.

3 Comments

It turns out that the python 3.X branch libraries were installed to a non-standard location, and that that was causing the issues, lol. Thanks, Graham! :D
How did you solve it....am having the same issue...am pointing my python home to my virtual env but its not working??
See modwsgi.readthedocs.io/en/develop/user-guides/… Don't use python-path, use python-home.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.