Error: Target WSGI script not found or unable to stat when run django on apache

16,766

Please notice how your apache configuration doesn't match the documented syntax for mod_wsgi's WSGIScriptAlias.

WSGIScriptAlias /blog/ "D:/Coding/xampp/htdocs/blog/django.wsgi"

should be:

WSGIScriptAlias /blog "D:/Coding/xampp/htdocs/blog/django.wsgi"

(notice no trailing slash after the 2nd token, "/blog")

I just resolved the same issue just now and found this thread Googling. Hope this helps you and future users.

For more information:

Share:
16,766
rocky
Author by

rocky

Updated on June 13, 2022

Comments

  • rocky
    rocky almost 2 years

    i have a problem when run django on apache:

    htdocs/blog/apps/homepage/urls.py:

    url(r'^$', 'index', name="h_index"),
    url(r'^about/$', 'about', name="h_about"),
    url(r'^contact/$', 'contact', name="h_contact"),
    url(r'^archive/$', 'archive', name="h_archive"),
    

    htdocs/blog/urls.py

    (r'^', include('apps.homepage.urls')),
    

    django.wsgi:

    import os
    import os.path
    import sys
    
    sys.path.append('D:/Coding/xampp/htdocs')
    sys.path.append('D:/Coding/xampp/htdocs/blog')
    
    os.environ['DJANGO_SETTINGS_MODULE'] = 'blog.settings'
    
    import django.core.handlers.wsgi
    application = django.core.handlers.wsgi.WSGIHandler()
    

    httpd.conf:

    Alias /static/ "D:/Coding/xampp/htdocs/blog/static/"
    WSGIScriptAlias /blog/ "D:/Coding/xampp/htdocs/blog/django.wsgi"
    

    when i run "localhost/blog", it's working. But run "localhost/blog/about/" or other, it's error:

    [error] [client ::1] Target WSGI script not found or unable to stat:   .../htdocs/blog/django.wsgiabout, referer: http://localhost/blog/