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

Scott Bratcher scott at 3floors.com
Thu Jan 31 05:17:45 EST 2008

Hello all,


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


RHEL5 / SELinux
Apache 2.2
Python 2.5.1
mod_pythonn 3.3.1
httpd.conf (not .htaccess)


.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/ 

If I comment out:
"#LoadModule python_module modules/mod_python.so"
and other related python lines Apache starts just fine without  
# service httpd start
Starting httpd:                                            [  OK  ]

Test as seen here: http://www.dscpl.com.au/wiki/ModPython/Articles/ 
# 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.


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.


More information about the Mod_python mailing list