<p>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.</p>

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

<p>My application is called tred.</p>

<p>Here are the relevant files:
httpd-vhosts (included in httpd-conf)</p>

<pre>
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


</pre>

<p>mod_wsgi-handle.wsgi</p>

<pre>
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()
</pre>

<p>When I go to <a href="http://tred" rel="noreferrer">http://tred</a> 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?</p>

[{'answer_id': 37009, 'author': 'John Millikin', 'author_id': 3560, 'author_profile': 'https://Stackoverflow.com/users/3560', 'pm_score': 4, 'selected': True, 'text': '<p>What happens if you remove the <code>Alias /</code> directive?</p>\n'}, {'answer_id': 37218, 'author': 'John Millikin', 'author_id': 3560, 'author_profile': 'https://Stackoverflow.com/users/3560', 'pm_score': 3, 'selected': False, 'text': '<blockquote>\n  <p>It works. I have no idea why, but it does.</p>\n</blockquote>\n\n<p>For future reference:</p>\n\n<p>It works because Apache processes alias directives in order, and uses the first match. It was always hitting <code>Alias /</code>, which will match anything, before <code>WSGIScriptAlias</code>.</p>\n\n<p>From the <a href="http://httpd.apache.org/docs/2.2/mod/mod_alias.html" rel="nofollow noreferrer"><code>mod_alias</code> documentation</a>:</p>\n\n<blockquote>\n  <p>First, all Redirects are processed before Aliases are processed, and therefore a request that matches a <code>Redirect</code> or <code>RedirectMatch</code> will never have Aliases applied. Second, the Aliases and Redirects are processed in the order they appear in the configuration files, with the first match taking precedence.</p>\n</blockquote>\n'}, {'answer_id': 1038110, 'author': 'Graham Dumpleton', 'author_id': 128141, 'author_profile': 'https://Stackoverflow.com/users/128141', 'pm_score': 3, 'selected': False, 'text': "<p>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.</p>\n"}, {'answer_id': 17796582, 'author': 'Shashank Singla', 'author_id': 2608199, 'author_profile': 'https://Stackoverflow.com/users/2608199', 'pm_score': 2, 'selected': False, 'text': '<p>try following this tutorial - <a href="http://singlas.in/5-step-tutorial-for-using-django-with-apache-and-mod_wsgi/" rel="nofollow">http://singlas.in/5-step-tutorial-for-using-django-with-apache-and-mod_wsgi/</a></p>\n\n<p>you are trying to host apache /var/www/ folder and the Django app both at root (/). Since Alias directive takes precedence over WSGIScriptAlias, it is rendering apache directory.</p>\n\n<p>you can try to host the django app at /app. Alternatively host the /var/www/ folder at a different location like /public</p>\n'}]
['https://Stackoverflow.com/questions/36806', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3431280/']