Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setup django with WSGI and apache

I have been sold on mod_wsgi and apache rather than mod_python. I have all the parts installed (django, apache, mod_wsgi) but have run into a problem deploying.

I am on osx 10.5 with apache 2.2 and django 1.0b2, mod_wsgi-2.3

My application is called tred.

Here are the relevant files: httpd-vhosts (included in httpd-conf)

NameVirtualHost tred:80



  ServerName tred

  Alias /admin_media /usr/lib/python2.5/site-packages/django/contrib/admin/media

  
    Order allow,deny
    Allow from all
  

  Alias /media /Users/dmg/Sites/tred/media

  
    Order allow,deny
    Allow from all
  

  Alias / /Users/dmg/Sites/tred/

  
        Order allow,deny
        Allow from all
    

  WSGIScriptAlias / /Users/dmg/Sites/tred/mod_wsgi-handler.wsgi

  WSGIDaemonProcess tred user=dmg group=staff processes=1 threads=10
  WSGIProcessGroup tred


mod_wsgi-handle.wsgi

import sys
import os

sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
os.environ['DJANGO_SETTINGS_MODULE'] = 'tred.settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

When I go to http://tred I get a directory listing rather than the rendered website. I think I have followed the tutorials correctly but it is obviously not right. What can I do to make this work?

like image 596
Doug Miller Avatar asked Aug 31 '08 12:08

Doug Miller


2 Answers

What happens if you remove the Alias / directive?

like image 149
John Millikin Avatar answered Oct 18 '22 19:10

John Millikin


Note that Alias and WSGIScriptAlias directives do not have the same precedence. Thus, they will not be processed in file order as written. Instead, all Alias directives get precedence over WSGIScriptAlias directives. Thus, it wouldn't have mattered if the Alias for '/' appeared after WSGIScriptAlias, it would still have taken precedence.

like image 27
Graham Dumpleton Avatar answered Oct 18 '22 21:10

Graham Dumpleton