Target WSGI script not found or unable to stat

1,377 views
Skip to first unread message

mojito

unread,
May 26, 2010, 6:42:46 PM5/26/10
to Django users
Hello,
I am trying to set up django 1.1.1 with mod_wsgi 2.3 and Apache
2.0.63 on Windows XP. My Python version is 2.4.4

I followed the instructions for installing and configuring mod_wsgi
from http://code.google.com/p/modwsgi/.

I set up the "Hello world " test first to see if my mod_wsgi install
is correct. That works.

When I come to deploy my django app on Apache , I get this error.

[error] [client 127.0.0.1] Target WSGI script not found or unable to
stat: C:/wsgi-django-app
/testing/apache/django.wsgi

Please help ...
Thanks
MP

My set up is as follows:
httpd.conf
---------------------
WSGIScriptAlias / C:/wsgi-django-app/testing/apache/django.wsgi

<Directory C:/wsgi-django-app/testing>
AllowOverride None
Options None
Order deny,allow
Allow from all
</Directory>

apache/django.wsgi
-------------------------------
import os, sys
sys.path.append('C:/wsgi-django-app')
sys.path.append('C:/wsgi-django-app/testing/apache')
sys.path.append('C:/Python24/Lib/site-packages/django')
os.environ['DJANGO_SETTINGS_MODULE'] = 'testing.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Graham Dumpleton

unread,
May 26, 2010, 7:51:48 PM5/26/10
to Django users

On May 27, 8:42 am, mojito <meenalp...@gmail.com> wrote:
> Hello,
> I am trying to set up django 1.1.1 with mod_wsgi 2.3  and Apache
> 2.0.63 on Windows XP. My Python version is 2.4.4
>
> I followed the instructions for installing and configuring mod_wsgi

> fromhttp://code.google.com/p/modwsgi/.


>
> I set up the "Hello world " test first to see if my mod_wsgi install
> is correct. That works.
>
> When I come to deploy my django app on Apache , I get this error.
>
>  [error] [client 127.0.0.1] Target WSGI script not found or unable to
> stat: C:/wsgi-django-app
> /testing/apache/django.wsgi

This will occur where the user that the Apache service runs as does
not have the necessary access permissions to the directory containing
the WSGI script file. In other works, if the access controls on your
directories only allow access to yourself and no one else, Apache
service will not be able to see the WSGI script file.

Graham

> Please help ...
> Thanks
> MP
>
> My set up is as follows:
> httpd.conf
> ---------------------
> WSGIScriptAlias / C:/wsgi-django-app/testing/apache/django.wsgi
>
> <Directory C:/wsgi-django-app/testing>

It is more secure to have:

<Directory C:/wsgi-django-app/testing/apache>

Graham

mojito

unread,
May 27, 2010, 4:27:09 PM5/27/10
to Django users
> > When I come to deploy my django app on Apache , I get this error.
>
> >  [error] [client 127.0.0.1] Target WSGI script not found or unable to
> > stat: C:/wsgi-django-app
> > /testing/apache/django.wsgi
>
> This will occur where the user that the Apache service runs as does
> not have the necessary access permissions to the directory containing
> the WSGI script file. In other works, if the access controls on your
> directories only allow access to yourself and no one else, Apache
> service will not be able to see the WSGI script file.
>
> Graham
>
Thanks for your response Graham. I do not think permissions is an
issue because I can launch a python script from this location and view
a test web page with Apache. If I use a *.wsgi file from here then
Apache complains. On Linux this setup works fine. What gives ?
Meenal

Graham Dumpleton

unread,
May 27, 2010, 8:17:23 PM5/27/10
to Django users


On May 28, 6:27 am, mojito <meenalp...@gmail.com> wrote:
> > > When I come to deploy my django app on Apache , I get this error.
>
> > >  [error] [client 127.0.0.1] Target WSGI script not found or unable to
> > > stat: C:/wsgi-django-app
> > > /testing/apache/django.wsgi
>
> > This will occur where the user that the Apache service runs as does
> > not have the necessary access permissions to the directory containing
> > the WSGI script file. In other works, if the access controls on your
> > directories only allow access to yourself and no one else, Apache
> > service will not be able to see the WSGI script file.
>
> > Graham
>
> Thanks for your response Graham. I do not think permissions is an
> issue because I can launch a python script

But you are launching the Python script as yourself aren't you?

Apache does not run as you but a distinct user which will have
different access permissions.

> from this location and view
> a test  web page with Apache.

And how did you do that? Was the page access in same 'apache'
subdirectory.

> If I use a *.wsgi file from here then
> Apache complains. On Linux this setup works fine. What gives ?

Change:

WSGIScriptAlias / C:/wsgi-django-app/testing/apache/django.wsgi

to:

Alias / C:/wsgi-django-app/testing/apache/django.wsgi

This will cause exact same file to be served as static file rather
than interpreted as WSGI script file. If you can't access it either,
then it is a permissions problem.

Graham
Reply all
Reply to author
Forward
0 new messages