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 webmaster@binshellpress.com
  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.

Druid
  • 133
  • 3
  • 12
  • 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. – FlipperPA Oct 15 '17 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. – Graham Dumpleton Oct 16 '17 at 00:21

1 Answers1

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?

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134
  • 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 – Druid Mar 24 '18 at 22:25
  • How did you solve it....am having the same issue...am pointing my python home to my virtual env but its not working?? – Joseph M Njuguna Oct 17 '18 at 11:52
  • See https://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html Don't use ``python-path``, use ``python-home``. – Graham Dumpleton Oct 19 '18 at 22:33