views:

27

answers:

1

This is a apache/mod_wsgi/virtualenv/django stack. In the virtualenv site-packages dir I've got a virtualenv_path_extensions.pth file. The apache conf has a

WSGIScriptAlias / /path/to/my.wsgi

my.wsgi has

site.addsitedir('/path/to/virtualenv/site-packages')

Now, if I start up a python shell, import site, and call the line above, my sys.path looks correct : it has loaded all the paths in the virtualenv_path_extensions.pth

However, Under apache I'm getting 500 errors because it claims django is not on the path. When I log sys.path after the addsitedir line in my.wsgi, it looks as if it has added the first line of virtualenv_path_extensions.pth, but not the rest!

What might cause that?

A: 

Ah, selinux :D

The paths that were not getting loaded had the wrong context, and apache wasn't able to touch them ...

** must remember to check those selinux logs when mysteries arise **

EMiller
From memory this can occur even when SELinux not used. Basically, if the additional directories aren't readable then site.addsitedir() will not add them. Thus need to ensure directories are readable to Apache user even where SELinux is not used.
Graham Dumpleton