[mod_python] Trouble importing files through mod_python

Tom Stambaugh brooklinetom at gmail.com
Mon Jun 2 18:18:05 EDT 2008


> You PythonPath is wrong for a start and would cause various issues,
> although not the immediate one here. You have:
>
> PythonPath "['/home/me/scratch', '/home/me/scratch/ImportTest',
> '/usr/lib/python2.5/', '/usr/lib/python2.5/lib-dynload/',
> '/usr/lib/python2.5/site-packages/']"
>
> It should be:
>
> PythonPath "['/home/me/scratch', '/home/me/scratch/ImportTest'] +
> sys.path"
>
> That is, you need to extend existing path, not replace it.

+10 on this!!!!

> Other than that, problems like this are generally due to the user that
> Apache runs as not being able to read files being imported. Thus,
> check whether permissions on your account directory and stuff in it
> are too restrictive and wouldn't allow another user to read the files
> contained there in.

I wonder if this is an SELinux problem. CentOS is constructed from Redhat,
and I wouldn't be surprised if it includes SELinux. I'm guessing that the
Ubuntu system did NOT have SELinux installed.

The way to check is to cd into /home/me/scratch and then do the following:

">ls -lZ *"

The "Z" switch will report the SELinux settings. You want to see a parameter

in each result that looks something like:
"user_u:object_r:httpd_sys_content_t"

The key is the last entry ... "httpd_sys_content_t" (at least in my
configuration).

To change the setting, run something like this (from within the "scratch"
directory):
">chcon -R -h -t httpd_sys_content_t *"

You might have to be root to accomplish this.

When I stumbled over this, it took days of agony before I found the answer.

Thanks,
Tom S.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20080602/94c1c35a/attachment.html


More information about the Mod_python mailing list