[mod_python] Apache Fails to load mod_python.so with Permission denied error under SELinux

Eric Brunson brunson at brunson.com
Thu Jan 31 11:13:08 EST 2008


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  ]
>
>
> Test as seen here: 
> http://www.dscpl.com.au/wiki/ModPython/Articles/GettingModPythonWorking
> # python
> Python 2.5.1 (r251:54863, Jan 30 2008, 20:46:46)
> [GCC 4.1.2 20070626 (Red Hat 4.1.2-14)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import mod_python.psp
> ImportError: No module named _apache
> >>>
>
> Server Output when starting Apache without mod_python:
> ----
> [Thu Jan 31 02:30:09 2008] [notice] SELinux policy enabled; httpd 
> running as context user_u:system_r:httpd_t:s0
> [Thu Jan 31 02:30:09 2008] [notice] suEXEC mechanism enabled (wrapper: 
> /usr/sbin/suexec)
> [Thu Jan 31 02:30:10 2008] [notice] Digest: generating secret for 
> digest authentication ...
> [Thu Jan 31 02:30:10 2008] [notice] Digest: done
> [Thu Jan 31 02:30:10 2008] [notice] Apache/2.2.3 (Red Hat) configured 
> -- resuming normal operations
> [Thu Jan 31 02:30:31 2008] [notice] caught SIGTERM, shutting down
> ----
> No error generated when Syntax Error prevents startup of Apache.
>
>
> QUESTIONS:
>
> I upgraded to Apache-2.2 then upgraded to  Python-2.5 then installed 
> the mod_python with ./configure,make,make install. should I have done 
> this in a different order?
>
> Could Apache's installation be pulling up python-2.4 and dislike a 
> mod_python installed for python-2.5? Is this what the error would look 
> like?
>
>
> Thanks to anyone who has time to offer aid.
>
> Scott
>
>
>
> _______________________________________________
> 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