Ubuntu 14.04.4 and Django 1.10
I'm trying to deploy a simple Django app that works perfectly in development to Apache, via WSGI. The relevant bits in my Apache config file:
<VirtualHost [my IP]>
WSGIScriptAlias /Django/MedFormUpdates /home/web/inside/django/MedFormUpdates/MedFormUpdates/wsgi.py
WSGIApplicationGroup %{GLOBAL}
</VirtualHost>
WSGIPythonPath /home/web/inside/django/MedFormUpdates/MedFormUpdates
<Directory "/home/web/inside/django/MedFormUpdates/MedFormUpdates">
Options ExecCGI
<Files wsgi.py>
Require all granted
</Files>
</Directory>
In my wsgi.py file:
import os, sys
from django.core.wsgi import get_wsgi_application
sys.path.append('/home/web/inside/django')
sys.path.append('/home/web/inside/django/MedFormUpdates')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MedFormUpdates.settings")
application = get_wsgi_application()
And in my settings.py:
WSGI_APPLICATION = 'MedFormUpdates.wsgi.application'
When I attempt loading the page, I get " We're sorry, the web server had an internal error. " - with the Apache log showing
End of script output before headers: wsgi.py
I've been through every Django/WSGI/Apache thread that I can find, and this is driving me nuts. Any insight is appreciated. Thanks.
It turns out that we have another Apache configuration file in the directory /etc/apache2/conf-enabled which has the following setting, which binds Python scripts (as well as Perl and CGI) to CGI:
AddHandler cgi-script .cgi .pl .py
This is necessary for many other things that we have in production. In order to except my project from that, in my Apache config file I removed
Options ExecGI
and instead put
RemoveHandler .py
which now has the page showing just fine.
This question is impossible to answer without more information on
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.