Reputation: 2168
So this is driving me crazy I have python3 and modwsgi and apache and a virtual host, that work great, as I have several other wsgi scripts that work fine on the server. I also have a django app that works great when I run the dev server.
I have checked that "ldd mod_wsgi.so" is linked correctly against python3.5
Whenever I try to access my site, I get an error and the apache log states: ImportError: No module named 'protectionprofiles' protection profiles is mysite name the following is my virtual host config
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ServerName <my ip>
WSGIScriptAlias /certs /var/www/scripts/CavsCertSearch/CavsCertSearch/certstrip.wsgi
WSGIScriptAlias /testcerts /var/www/scripts/CavsCertSearchTest/CavsCertSearch/certstriptest.wsgi
WSGIScriptAlias /protectionprofiles /var/www/protectionprofiles/protectionprofiles/wsgi.py
<Directory /var/www/protectionprofiles/protectionprofiles>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
my site app is the protection profiles alias. I have no idea what the issue is I have tried following dozens of different apache tutorials and none of them seem to work. Any help is greatly appreciated.
------ To add something else I tried -------- so I added the following 2 commands inside the virtual host
WSGIDaemonProcess protectionprofiles python-path=/var/www/protectionprofiles/
WSGIProcessGroup protectionprofiles
and no I get a different error
Error was: No module named 'django.db.backends.postgresql'
which is my backend, but the dev server works fine? Below is my database configuration
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'USER': 'myuser',
'PASSWORD': 'abcd1234',
'HOST': '127.0.0.1',
'PORT': '5432',
'NAME': 'protectionprofile',
}
}
----Another error ---- Occasional I get
RuntimeError: populate() isn't reentrant
---- Another error!!--- Now when I update
WSGIDaemonProcess protectionprofiles python-path=/var/www/protectionprofiles/:/usr/lib/python3/dist-packages/django
I get
ImportError: cannot import name 'SimpleCookie'
---Another wierd thng is that when I have
WSGIProcessGroup protectionprofiles
enabled I dont get the error that it can't find the module "protectionprofiles" but when then non of my other wsgi scripts work!. They only work when thats no in there. Any explanation of that would be very helpful
Upvotes: 0
Views: 1094
Reputation: 2168
ok I finally figured out how to fix the issue but not sure exactly why. First off when I was mixing my own wsgi scipts and django I had to specify the daemon process only for the script alias that was django
WSGIScriptAlias /certs /var/www/scripts/CavsCertSearch/CavsCertSearch/certstrip.wsgi
WSGIScriptAlias /testcerts /var/www/scripts/CavsCertSearchTest/CavsCertSearch/certstriptest.wsgi
WSGIScriptAlias /debug /var/www/scripts/debug/debug.wsgi
WSGIScriptAlias / /var/www/protectionprofiles/protectionprofiles/wsgi.py process-group=protectionprofiles
WSGIDaemonProcess protectionprofiles python-path=/var/www/protectionprofiles/
WSGIProcessGroup protectionprofiles
Then in the app/settings.py in dev mode one backend worked but when ran in mod_wsgi I needed a different one: settings.py:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'databse',
'USER': 'user',
'PASSWORD': '',
'HOST': 'localhost',
'PORT': '5432',
}
}
In the development server "'django.db.backends.postgresql" worked fine but in release I had to specify the exact module type. I am not sure why but it works now!!
Upvotes: 0
Reputation: 58563
You probably need to tell mod_wsgi where your project code is. For embedded mode this is done with WSGIPythonPath
directive. You should preferably though use daemon mode, in which case you would use python-path
option to WSGIDaemonProcess
directive.
Upvotes: 1