0

This problem has tortured me for days. I am using Apache, WSGI and django on my Raspberry Pi. Operating system is Raspbian.

Everything is okay except this error from apache.

[error] [client 127.0.0.1] Target WSGI script not found or unable to stat: /home/pi/EZ_Green/apache/ems_gateway_django.wsgi

My configuration file is like this, pretty straightforward

WSGIDaemonProcess ems.ezgreenbuildings.com processes=1 maximum-requests=100 threads=10
WSGIScriptAlias / /home/pi/EZ_Green/apache/ems_gateway_django.wsgi

The file path is the full path for sure. So the file exists. Then I thought the apache server process does not have the permission to access the file, so I changed the mode of wsgi file to 777. But it still reports the same error.

I have searched for a while, and tried several methods.

  1. move the wsgi file to another foler, say '/var/www', but it still cannot find it.
  2. try to reinstall apache, does not work.
  3. remove trailing slash

The strange thing is, apache is working fine if I remove the wsgi configuration file. And django itself is working fine if I run test server provided by django.

If anyone can help, I would be very glad. Thanks!

2
  • Did you try to see if Apache could really read the file by pretending to be the Apache user? Try something like sudo -u www-data cat /home/pi/EZ_Green/apache/ems_gateway_django.wsgi may help. Dec 25, 2013 at 16:57
  • Thanks. It is the permission problem, I changed the permission of the directory and it's solved.
    – Jiechao Li
    Dec 26, 2013 at 1:34

1 Answer 1

1

Do you have SELinux extensions enabled, preventing Apache from accessing the directories where the files exist?

Are the permissions on the home directory going to allow Apache access? It is not sufficient for just the file to be readable, all the directories down to it must also be accessible.

Unrelated, but do you have a WSGIProcessGroup directive to correspond to WSGIDaemonProcess so that requests will actually be delegated to run in the daemon process?

Finally, you can leave off 'processes=1' as it defaults to a single process and setting 'processes' for any number has other implications because it will flag in WSGI environment that it is a multi process configuration.

4
  • Thanks a lot. It is the permission problem, I changed the permission of the directory and it's solved. I don't have a WSGIProcessGroup. Is it important? I will look into this.
    – Jiechao Li
    Dec 26, 2013 at 1:35
  • WSGIDaemonProcess only says to create a daemon process. By itself it doesn't result in anything being run it it. You still need to separately say what should be run in it. See blog.dscpl.com.au/2012/10/… Dec 26, 2013 at 2:02
  • Thanks! Graham. Your blog is awesome. I have one more questions. Usually I will access the site by it's IP address, and it does not have a domain name. So can I use '127.0.0.1' instead of a real domain name like 'example.com'? Like this 'WSGIProcessGroup 127.0.0.1'
    – Jiechao Li
    Dec 26, 2013 at 11:01
  • The name argument to WSGIDaemonProcess/WSGIProcessGroup can be anything you want. Nothing to do with your site name. They just need to match. Dec 27, 2013 at 2:22

Not the answer you're looking for? Browse other questions tagged .