Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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/urls.py to add the following line in the urlpatterns tuple:

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

Next, I created hello/views.py 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 31.182.131.38] 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:
    sys.path.append(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

1 Answer 1

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

 
discard

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.