Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

In my /etc/apache2/sites-enabled, i have a file, which defines a virtual host as follows :

<VirtualHost *:80>
  ServerAdmin hostmaster@wharfage
  DirectoryIndex index.html index.htm index.php
  DocumentRoot /var/www
  LogLevel debug
  ErrorLog /var/log/apache2/site2_error.log
  CustomLog /var/log/apache2/site2_access.log combined
  ServerSignature Off

  <Location />
    Options -Indexes

  Alias /favicon.ico /srv/site2/static/favicon.ico

  Alias /static /srv/site2/static
#  Alias /media  /usr/local/lib/python2.5/site-packages/django/contrib/admin/media

Alias /admin/media /var/lib/python-support/python2.5/django/contrib/admin/media 

  WSGIScriptAlias / /srv/site2/wsgi/django.wsgi

  WSGIDaemonProcess site2 user=samj group=samj processes=1 threads=10
  WSGIProcessGroup site2

I do the following to enable the site :

1) In /etc/apache2/sites-enabled, i run the command a2ensite

2) I then get a message site successfully enabled, and then i run the command /etc/init.d/apache2 reload.

But, if i navigate to, i get 404 not found. I do have an index.html in /var/www (permissions:777 and ownership www-data:www-data), and i have also verified that a symlink was created for in /etc/apache2/sites-enabled.

Any way to fix this ?

Thank you.

share|improve this question

Your WSGIScriptAlias directive is saying to send everything except for explicit Alias matched static files, through to Django. Thus, if you are trying to access index.html explicitly it will not use the static one and if Django doesn't know what to do with it, it will return a 404. What is the actual URL you are using? For that URL, do you have matching configuration in Django for it so Django knows what to do?

Alternatively, issue may be because you don't actually have a /srv/site2/wsgi/django.wsgi file, or because you have not set up an Allow directive for /srv/site2/wsgi like Django/mod_wsgi documentation says you should although lack of that would normally result in 403.

Suggest you comment out WSGIScriptAlias and see what happens first. You would then need to properly explain how you want things to work with actual examples. Reading Django integration guide on mod_wsgi site may also be a good idea.

share|improve this answer
Thanks Graham for the wonderful response :)...everything works now..thanks a lot :) – qubit Nov 24 '09 at 19:58

Do you have a:

NameVirtualHost *:80

in your configuration? You need to include this in somewhere (ports.conf on Debian) in your apache configuration, then restart apache.

share|improve this answer

Your Answer


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