Reputation: 3506
From my Apache error log.
[Tue Jan 26 00:37:50.840680 2016] [:error] [pid 6522] [client 70.70.241.146:57247] mod_wsgi (pid=6522): Target WSGI script '/var/www/site/public_html/project/apache/wsgi.py' cannot be loaded as Python module.
[Tue Jan 26 00:37:50.840791 2016] [:error] [pid 6522] [client 70.70.241.146:57247] mod_wsgi (pid=6522): Exception occurred processing WSGI script '/var/www/site/public_html/project/apache/wsgi.py'.
[Tue Jan 26 00:37:50.840852 2016] [:error] [pid 6522] [client 70.70.241.146:57247] Traceback (most recent call last):
[Tue Jan 26 00:37:50.841081 2016] [:error] [pid 6522] [client 70.70.241.146:57247] File "/var/www/site/public_html/project/apache/wsgi.py", line 23, in <module>
[Tue Jan 26 00:37:50.841094 2016] [:error] [pid 6522] [client 70.70.241.146:57247] application = get_wsgi_application()
[Tue Jan 26 00:37:50.841252 2016] [:error] [pid 6522] [client 70.70.241.146:57247] File "/opt/env/lib/python3.4/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Tue Jan 26 00:37:50.841264 2016] [:error] [pid 6522] [client 70.70.241.146:57247] django.setup()
[Tue Jan 26 00:37:50.841400 2016] [:error] [pid 6522] [client 70.70.241.146:57247] File "/opt/env/lib/python3.4/site-packages/django/__init__.py", line 17, in setup
[Tue Jan 26 00:37:50.841412 2016] [:error] [pid 6522] [client 70.70.241.146:57247] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Tue Jan 26 00:37:50.841619 2016] [:error] [pid 6522] [client 70.70.241.146:57247] File "/opt/env/lib/python3.4/site-packages/django/conf/__init__.py", line 48, in __getattr__
[Tue Jan 26 00:37:50.841632 2016] [:error] [pid 6522] [client 70.70.241.146:57247] self._setup(name)
[Tue Jan 26 00:37:50.841672 2016] [:error] [pid 6522] [client 70.70.241.146:57247] File "/opt/env/lib/python3.4/site-packages/django/conf/__init__.py", line 44, in _setup
[Tue Jan 26 00:37:50.841682 2016] [:error] [pid 6522] [client 70.70.241.146:57247] self._wrapped = Settings(settings_module)
[Tue Jan 26 00:37:50.841715 2016] [:error] [pid 6522] [client 70.70.241.146:57247] File "/opt/env/lib/python3.4/site-packages/django/conf/__init__.py", line 92, in __init__
[Tue Jan 26 00:37:50.841725 2016] [:error] [pid 6522] [client 70.70.241.146:57247] mod = importlib.import_module(self.SETTINGS_MODULE)
[Tue Jan 26 00:37:50.842007 2016] [:error] [pid 6522] [client 70.70.241.146:57247] File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
[Tue Jan 26 00:37:50.842054 2016] [:error] [pid 6522] [client 70.70.241.146:57247] return _bootstrap._gcd_import(name[level:], package, level)
[Tue Jan 26 00:37:50.842088 2016] [:error] [pid 6522] [client 70.70.241.146:57247] File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
[Tue Jan 26 00:37:50.842112 2016] [:error] [pid 6522] [client 70.70.241.146:57247] File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
[Tue Jan 26 00:37:50.842135 2016] [:error] [pid 6522] [client 70.70.241.146:57247] File "<frozen importlib._bootstrap>", line 2212, in _find_and_load_unlocked
[Tue Jan 26 00:37:50.842158 2016] [:error] [pid 6522] [client 70.70.241.146:57247] File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
[Tue Jan 26 00:37:50.842181 2016] [:error] [pid 6522] [client 70.70.241.146:57247] File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
[Tue Jan 26 00:37:50.842203 2016] [:error] [pid 6522] [client 70.70.241.146:57247] File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
[Tue Jan 26 00:37:50.842225 2016] [:error] [pid 6522] [client 70.70.241.146:57247] File "<frozen importlib._bootstrap>", line 2212, in _find_and_load_unlocked
[Tue Jan 26 00:37:50.842247 2016] [:error] [pid 6522] [client 70.70.241.146:57247] File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
[Tue Jan 26 00:37:50.842269 2016] [:error] [pid 6522] [client 70.70.241.146:57247] File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
[Tue Jan 26 00:37:50.842291 2016] [:error] [pid 6522] [client 70.70.241.146:57247] File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
[Tue Jan 26 00:37:50.842313 2016] [:error] [pid 6522] [client 70.70.241.146:57247] File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked
[Tue Jan 26 00:37:50.842346 2016] [:error] [pid 6522] [client 70.70.241.146:57247] ImportError: No module named 'mysite'
And then in my hosts file:
WSGIScriptAlias / /var/www/site/public_html/project/apache/wsgi.py
<Directory "/var/www/site/public_html/project/apache">
Require all granted
</Directory>
Alias /static/ /var/www/site/public_html/app/static
<Directory /var/www/site/public_html/app/static>
Require all granted
</Directory>
And outside of the VirtualHost:
WSGIPythonPath /var/www/site/public_html/:/opt/env/lib/python3.4/site-packages
Here is the wsgi.py
:
import os, sys
apache_configuration= os.path.dirname(__file__)
project = os.path.dirname(apache_configuration)
workspace = os.path.dirname(project)
sys.path.append(workspace)
sys.path.append(project)
sys.path.append('/var/www/site/public_html/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.apache.override'
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
I've already tried sudo apt-get install libapache2-mod-wsgi-py3
. I've already changed the python path. Not sure what else to try.
Where can I look to next?
I am on Ubuntu 14.
Upvotes: 3
Views: 6094
Reputation: 599798
You've set your DJANGO_SETTINGS_MODULE to "mysite.apache.override", but you don't have anything called "mysite"; your project is "project", so your settings module is in "project.apache.override".
Note also that you really shouldn't be putting your code under public_html, and preferably not under /var/www at all; it shouldn't be anywhere where it could mistakenly be served directly by the webserver.
Upvotes: 5