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

I've a django app that works perfectly under the django development server. I'm trying to deploying it in apache2.2 using the mod_wsgi and I have errors. In the httpd.conf file I "mounted" my app under the root /myapp using:

<IfModule wsgi_module>
    WSGIScriptAlias /myapp my_path_to_wsgi_module/django.wsgi
    WSGIScriptReloading On
    WSGIDaemonProcess djangoapps processes=10 threads=1 maximum-requests=500 display-name=my-wsgi
    WSGIProcessGroup djangoapps

I've followed the standard indication to prepare django.wsgi. Now, I can reach the main page template of my app but it seems to have redirection errors. The "/myapp" root is not inserted automatically on ULRs redirection requests. Request from the main page template to some modules in via cannot be correctly delivered.

apache access log: - - [21/Feb/2011:16:11:44 +0100] "GET /myapp/ HTTP/1.1" 200 1795 - - [21/Feb/2011:16:11:46 +0100] "GET /api/dir HTTP/1.1" 404 205

"/api/dir" doesn't exist, it should be matched from a pattern in, but id doesn't.

apache error log:

[Tue Feb 21 16:11:46 2011] [error] [client] File does not exist: /home/my_path_to_django_app_superfolder/api, referer:

I've spent more than 2 days with it, please can somebody help?

share|improve this question
up vote 1 down vote accepted

Finally I found the error. It was not connected to httpd.conf file but to how URLs are specified both to django file and to templates.
As I mounted myapp in this way:

WSGIScriptAlias /myapp my_path_to_wsgi_module/django.wsgi

I was believing that URLs specified in django template files should carry an initial slash, like this: '/api/dir'
It results that in this way the application works only on django development server but not on apache.

Instead if you use URLs without initial slash like:
The app works correctly both on django development server and on apache!

You must avoid using starting slashes even on pattern matching of django file:
like this: (r'^api/dir$', 'available_services')
and NOT like this: (r'^/api/dir$', 'available_services')

Maybe this is an obvious thing for expert django users but if you're novice like me, this can make you loose a certain amount of time because it's a hard problem to be detected.

share|improve this answer

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.