[mod_python] Apache Fails to load mod_python.so on Windows

Graham Dumpleton graham.dumpleton at gmail.com
Thu Jan 31 17:08:54 EST 2008


Please don't follow up to a different thread with a new question.
Subject now changed.

If you are running Apache as a service, it may be running as a
specific user, not the one which you installed the mod_python code as.
If this is the case, you need to make sure that the user that Apache
is running as has correct access rights to be able to read the module
file.

If this has occurred, you may also have problems with loaded module
then being able to read the installed Python code files.

Generally it is recommended that Apache, Python and mod_python all be
installed as an administrator and not as an individual user.

Graham

On 01/02/2008, Manjula Kumar <emailmanjula at yahoo.com> wrote:
> Hi All,
>  I downloaded mod_python3.3.1 for Apache 2.2 and python 2.5 for Windows.But
> when i restart the apache it is giving the error,
> httpd.exe: Syntax error on line 116 of C:/Program Files/Apache Software
> Foundation/Apache2.2/conf/httpd.conf: Cannot load
> C:/Program Files/Apache Software
> Foundation/Apache2.2/modules/mod_python.so into server: The
> specified module could not be found.
> But i am able to see the mod_python load module installed.
>  If I comment out:
>  #LoadModule python_module modules/mod_python.so
>   Apache starts just fine without.
>
> Can anyone let me know what I am doing wrong.
>
> Thanks,
> Manjula
>
>
> Eric Brunson <brunson at brunson.com> wrote:
> Scott Bratcher wrote:
> > Thanks Eric,
> >
> > "setenforce 0" THIS WORKED. Apache started right up
> >
> > Below are the results of my attempts as you suggested. I think we are
> > onto the problem because with SELinux enforced it loads right up.
> > However, the chcon command failed to clear up the problem. I'm new to
> > SELinux. Is there another possible SELinux related permission that may
> > be the solution? It's just mod_python that is giving this problem even
> > though all of the others share the same t permission httpd_module.
> >
> > # ls -Zd modules
> > drwxr-xr-x root root system_u:object_r:httpd_modules_t
> modules/
> >
> > So I changed the permissions:
> >
> > # chcon -t texrel_shlib_t
> /etc/httpd/modules/mod_python.so
> > # service httpd start
> > Starting httpd: httpd: Syntax error on line 210 of
> > /etc/httpd/conf/httpd.conf: Syntax error on line 6 of
> > /etc/httpd/conf.d/python.conf: Cannot load
> > /etc/httpd/modules/mod_python.so into server:
> > /etc/httpd/modules/mod_python.so: cannot restore segment
> prot after
> > reloc: Permission denied
> > [FAILED]
> > # ls -Z /etc/httpd/modules/mod_python.so
> > -rwxr-xr-x root root system_u:object_r:textrel_shlib_t
> > /etc/httpd/modules/mod_python.so*
>
> I'm far from an expert in selinux, so this could be hit and miss. The
> google article I was reading may have been out of date, I know selinux
> policies have been under heavy development in Fedora and RHEL.
>
> Try:
>
> chcon -t system_u:object_r:httpd_modules_t
> /etc/httpd/modules/mod_python.so
>
> Later,
> e.
>
> >
> >
> >
> > I also tried changing the permissions of the 2.5 site-packages to the
> > same permissions as the previously working 2.4 site-packages, plus the
> > other listed below, and the still Apache Failure occurs.
> >
> > # ls -Zd /usr/local/lib/python2.5/site-packages/
> > /usr/lib/python2.4/site-packages/
> > drwxr-xr-x root root system_u:object_r:lib_t
> > /usr/lib/python2.4/site-packages/
> > drwxr-xr-x root root user_u:object_r:lib_t
> > /usr/local/lib/python2.5/site-packages/
> >
> > system_u:object_r:lib_t
> > system_u:object_r:textrel_shlib_t
> > user_u:object_r:textrel_shlib_t
> >
> >
> > If you have other tips I'd appreciate any help you can offer.
> >
> > Scott
> >
> >
> >
> > On Jan 31, 2008, at 10:13 AM, Eric Brunson wrote:
> >
> >> Scott Bratcher wrote:
> >>> Hello all,
> >>>
> >>>
> >>> THE PROBLEM:
> >>>
> >>> Starting Apache results in this error:
> >>>
> >>> # service httpd start
> >>> Starting httpd: httpd: Syntax error on line 210 of
> >>> /etc/httpd/conf/httpd.conf: Syntax error on line 6 of
> >>> /etc/httpd/conf.d/python.conf: Cannot load
> >>> /etc/httpd/modules/mod_python.so into server:
> >>> /etc/httpd/modules/mod_python.so: cannot restore
> segment prot after
> >>> reloc: Permission denied
> >>> [FAILED]
> >>>
> >>
> >> This error message is often related to selinux permissions.
> >>
> >> A quick check to see if that is the problem is to disable selinux
> >> with the command (as root) "setenforce 0". If the module then loads
> >> correctly, it can be fixed permanently with the command:
> >>
> >> chcon -t texrel_shlib_t /etc/httpd/modules/mod_python.so
> >>
> >> Then, re-enable selinux with "setenforce 1".
> >>
> >> If disabling selinux does not fix the problem, then more
> >> investigation is required.
> >>
> >> Hope that helps,
> >> e.
> >>
> >>> USING:
> >>>
> >>> RHEL5 / SELinux
> >>> Apache 2.2
> >>> Python 2.5.1
> >>> mod_pythonn 3.3.1
> >>> httpd.conf (not .htaccess)
> >>>
> >>>
> >>> TESTED THUS FAR:
> >>>
> >>> .so file exists with same permissions as other modules
> >>> # ls -Z /etc/httpd/modules/mod_python.so
> >>> -rwxr-xr-x root root system_u:object_r:httpd_modules_t
> >>> /etc/httpd/modules/mod_python.so*
> >>>
> >>> If I comment out:
> >>> "#LoadModule python_module modules/mod_python.so"
> >>> and other related python lines Apache starts just fine without
> >>> mod_python.
> >>> # service httpd start
> >>> Starting httpd: [ OK ]
> >>>
> >>>
> >>>
> >>
> >
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
>
>
>
>  ________________________________
> Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it
> now.
>
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
>
>


More information about the Mod_python mailing list