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

Recently, I wanted to put one of my WSGI applications into a subdirectory, so that the other directories that cointain various scripts would work as before. In order to do that, I added the following directive to my httpd.conf in global namespace (also tried to put it in the VirtualHost, which gave the same effects):

WSGIScriptAlias /hello/ /var/www/hello/hello.wsgi

Then, I ran django-admin startproject hello. After reloading Apache configs, I can confirm that http://localhost/hello/ points to a Django "welcome" screen. Then, I edited hello/ to add the following line in the urlpatterns tuple:

url(r'^hello/', 'hello.views.home'),

Next, I created hello/ with the following contents:

from django.http import HttpResponse

def hello(request):
    return HttpResponse("Hello world")

Unfortunately, when I try to visit http://localhost/hello/hello, I get a standard Apache 404 message and the following entry in the error log:

[Mon Dec 23 19:49:44 2013] [error] [client] Target WSGI script not found or unable to stat: /var/www/hello/hello.wsgihello

Note the hello.wsgihello. The second hello is the text that appears after /hello/ in the URL. For http://localhost/hello/unknown, it would be hello.wsgiunknown. Here's my hello.wsgi:

import os
import sys

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

path = '/var/www/hello'
if path not in sys.path:

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

Did I do something wrong? How do I fix it?

share|improve this question

The file syntax in /var/www/hello/hello.wsgi confused me. Apparently, if one points to /var/www/hello/hello.wsgi/ instead, the configuration works fine.

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.