Selinux blocks wordpress in CentOS 6.3

Antonio asked:

I installed wordpress 3.5 to CentOS 6.3 using command:

yum install wordpress

and started httpd. Now I can see the following error in apache log:

PHP Fatal error: require_once(): Failed opening required
(include_path=’.:/usr/share/pear:/usr/share/php’) in
/usr/share/wordpress/wp-includes/class-feed.php on line 4, referer:

I guess that that’s because of SELinux:

ls -Z /usr/share/wordpress/wp-includes/class-simplepie.php 
lrwxrwxrwx. root root system_u:object_r:usr_t:s0 class-simplepie.php -> /usr/share/php/php-simplepie

ls -Z /usr/share/php/php-simplepie
-rw-r--r--. root root unconfined_u:object_r:user_home_t:s0 autoloader.php
drwxr-xr-x. root root unconfined_u:object_r:user_home_t:s0 SimplePie
-rw-r--r--. root root unconfined_u:object_r:user_home_t:s0 SimplePie.php

I wonder if there is a way to let it work without disabling SELinux?

My answer:

It looks like your files have the wrong SELinux security contexts. When I install the php-simplepie package (it appears to come from EPEL) and inspect those files, they all have the usr_t type, rather than user_home_t.

Try fixing the security labels:

restorecon -r -v /usr/share/php/php-simplepie

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.