Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is my first time trying to setup a webserver with Django. I've been banging my head against the wall in trying to set this up for a while now and I can't seem to find any resources that explains this in a newbie formatted step by step manner.

I've installed and setup apache and mod_wsgi on my EC2 instance. How do I map the URLs of my app set in my file to apache? Locally, I can get my app to work my entering by running it on the Django development server. I'm trying to be able to get this to work on my public dns as with apache and mod_wsgi.

When I restart my Apache server, I also get this error but with OK status [error] (EAI 2)Name or service not known: Could not resolve host name *.80 -- ignoring

Below lists the relevant snippets

django.wsgi file

import os,sys

apache_configuration = os.path.dirname(__file__)
project = os.path.dirname(apache_configuration)
workspace = os.path.dirname(project)

os.environ['DJANGO_SETTINGS_MODULE'] = 'flickr.settings'

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

httpd.conf file

<VirtualHost *.80>
    DocumentRoot /home/djangotest/flickr
    ErrorLog /home/djangotest/flickr/logs/apache_error.log
    CustomLog /home/djangotest/flickr/logs/apache_access.log combined
    WSGIScriptAlias / /home/djangotest/flickr/apache/django.wsgi

    <Directory /home/djangotest/flickr/media>
        Order deny,allow
        Allow from all

    <Directory /home/djangotest/flickr/apache>
        Order deny,allow
        Allow from all

    LogLevel warn

    WSGIDaemonProcess user=djangotest processes=2 threads=25

    Alias /media/ /home/djangotest/flickr/media/

from django.conf.urls.defaults import *

urlpatterns = patterns('',
    # Example:
    (r'flickr/', include('flickrphotobrowser.urls')),
) (located in my app)

from django.conf.urls.defaults import *

from flickrphotobrowser.views import *

urlpatterns = patterns('flickrphotobrowser.views',
        (r'^phototags/$', contenttags),
        (r'^photouser/$', contentuser),

ROOT_URLCONF = 'flickr.urls'

        os.path.join(os.path.basename(__file__), 'templates'),
    #'home/nai/Projects/flickr/flickrphotobrowser/templates', # THIS IS FOR LOCAL ONLY


Should I include any other snippets to help troubleshoot the problem? Thanks.

share|improve this question
Couple of typos: the method names in the urls should be enclosed in quotations as well. So it should be 'contenttags' and 'contentuser' – Nai Mar 23 '11 at 9:12
up vote 1 down vote accepted

In your httpd conf, change:

<VirtualHost *.80>


<VirtualHost *:80>

and restart Apache.

If that doesn't fix it, you could also try adding:


to your django.wsgi file.

share|improve this answer
Ok changing to <VirtualHost *:80> worked but now I'm getting an error You don't have permission to access /flickr/photouser on this server.(OMG A TYPO URGHHHHHHHHHH) – Nai Mar 23 '11 at 8:25
Don't worry, Steve has a mistake in his answer as well. The path supplied to sys.path.append should be quoted but ServerFault doesn't allow trivial edits for me. BTW, also make sure you have 'NameVirtualHost *:80' directive as well else name virtual hosts will not resolve properly. – Graham Dumpleton Mar 23 '11 at 10:33
@Graham Yes I saw that in the apache error logs! I also had a couple of permission issues which I fixed by changing the User and Group values. I was able to debug the rest of my problems after making the change he spotted. – Nai Mar 23 '11 at 10:46
Fixed - thanks. – Steve Mayne Mar 23 '11 at 12:00
You shouldn't normally be changing the User/Group of Apache itself. If using mod_wsgi you would be better off using daemon mode and have just the Python web application process run as different user/group y setting the user/group options to WSGIDaemonProcess. Only the WSGI script file then has to be readable/accessible to Apache user. Watch '…;. – Graham Dumpleton Mar 23 '11 at 20:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.