I am currently doing research whether Python and Django are fit for a project that I'm going to work on (so far it looks good). As a means of a test, I want to get python running on an actual server (apache2 on ubuntu), using mod_wsgi, but I just can't make it work. Here is my httpd.conf (located at /etc/apache2/httpd.conf):
WSGIScriptAlias /test/tc-test/ /var/www/stage/hello/tc-test/django.wsgi
WSGIPythonPath /var/www/stage/test/tc-test/
<Directory /var/www/stage/test/tc-test>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
My django.wsgi looks as follows:
import os
import sys
sys.path.append('/var/www/stage/test/tc-test')
os_environment['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
The url for this directory will be http://stage.website.com/test/tc-test
Strangely enough, when I reboot the apache server, I keep getting 500 internal server errors. Not just for that subdirectory, but for all other subdirectories on the server. I looked at the apache error log, but for some reason no error is being logged at all. I managed to narrow down the culprits to WSGIScriptAlias and WSGIPythonPath: when I remove both of them, the 500 internal server errors disappear, and when I add any of them, they appear again. I have confirmed that mod_wsgi is working like it should, and it's probably something very simple that I'm looking over. I just can't find out what. Any help on this?
Description: Maps a URL to a filesystem location and designates the target as a WSGI script.
mod_wsgi is an Apache HTTP Server module by Graham Dumpleton that provides a WSGI compliant interface for hosting Python based web applications under Apache. As of version 4.5. 3, mod_wsgi supports Python 2 and 3 (starting from 2.6 and 3.2).
If installing the Apache module by hand, the file is called 'mod_wsgi.so'. The compiled Apache module can be found in the “. libs” subdirectory.
Try:
WSGIScriptAlias /test/tc-test /var/www/stage/hello/tc-test/django.wsgi
You shouldn't have trailing slash on first argument.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With