Reputation: 105
Ok sorry I know this question is similar to another but when I tried the other answer did not seem to work for me. Apache2.2:ImportError: No module named site. So I am trying to get django/virtualenv/apache working together. Any help is greatly appreciated!!
Here are the error logs.
Here is my apache conf file
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ServerName tracker.com
<Directory /var/www/html/drish/drish>
<Files wsgi.py>
Require all granted
</Files>
order allow,deny
allow from all
</Directory>
WSGIDaemonProcess project python-path=/var/www/html/drish/:python-home=/var/www/html/virtenv
WSGIScriptAlias / /var/www/html/drish/drish/wsgi.py
Alias /static /var/www/html/drish/drish
</VirtualHost>
I have not changed anything in the wsgi.conf
file all I did was enable it. Though I did see some options in there but not sure what any of them do.
Here is the WSGI.py file that was created by django which I have also changed nothing.
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "drish.settings")
application = get_wsgi_application()
Again thanks for any help.
Upvotes: 4
Views: 138
Reputation: 2269
From your error log, it appears that there are a couple potential problems, including that it can't import drish.settings
, as well as the fact that it's not using the Python binary in your virtual environment. I think you need to solve the latter problem first, before figuring out why drish.settings
won't import, so let's verify a few things.
First, are you sure about the syntax in your WSGIDaemonMode
directive? The docs look to be slightly different than what you have above, with respect to the python-path
value. Here's their example from the docs:
WSGIDaemonProcess example.com python-path=/path/to/mysite.com:/path/to/venv/lib/python2.7/site-packages
WSGIProcessGroup example.com
And here's what I think yours should look like:
WSGIDaemonProcess project python-path=/var/www/html/drish/:/var/www/html/virtenv/lib/python2.7/site-packages
WSGIProcessGroup project
Clearly you will want to verify that the /var/www/html/virtenv/lib/python2.7/site-packages
directory does indeed exist, I'm making an educated guess about that particular location.
It's entirely possible that this will solve both problems, but I'm not 100% certain about that. Either way, give this a try and let us know how you get on. Ideally you'll at least start seeing that it's using the python binary in your virtual environment, instead of the system one.
Upvotes: 3