Saturday, February 16, 2013

Configuring SELinux for Centeron 2.4 on CentOS 6.3

  • CentOS 6.3 x64
  • Centreon 2.4

Problem


During Centreon installation when the tool starts up, the website is blank and nothing's happening.



I can observe the following error in /var/log/httpd/error_log:
[Sat Feb 16 18:07:58 2013] [error] [client 192.168.189.63] PHP Fatal error:  Smarty error: unable to write to $compile_dir '/usr/local/centreon/GPL_LIB/SmartyCache/compile'. Be sure $compile_dir is writable by the web server user. in /usr/local/centreon/GPL_LIB/Smarty/libs/Smarty.class.php on line 1095, referer: http://192.168.189.36/centreon/install/setup.php

Other errors can also be seen in the log but those are irrelevant:
[Sat Feb 16 18:29:29 2013] [error] [client 192.168.189.63] PHP Fatal error:  require_once(): Failed opening required 'www/class/centreonXMLBGRequest.class.php' (include_path='.:/usr/share/pear:/usr/share/php') in /usr/local/centreon/www/include/monitoring/status/TopCounter/xml/ndo/statusCounter.php on line 43, referer: http://192.168.189.36/centreon/main.php?p=61701&num=1&limit=30&poller=&template=&search=&type=&o=&search_type_service=1&search_type_host=1&search_service=
[Sat Feb 16 18:29:31 2013] [error] [client 192.168.189.63] PHP Warning:  include_once(/etc/centreon/centreon.conf.php): failed to open stream: No such file or directory in /usr/local/centreon/www/include/monitoring/status/TopCounter/xml/ndo/statusCounter.php on line 41, referer: http://192.168.189.36/centreon/main.php?p=604
[Sat Feb 16 18:29:31 2013] [error] [client 192.168.189.63] PHP Warning:  include_once(): Failed opening '/etc/centreon/centreon.conf.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /usr/local/centreon/www/include/monitoring/status/TopCounter/xml/ndo/statusCounter.php on line 41, referer: http://192.168.189.36/centreon/main.php?p=604
[Sat Feb 16 18:29:31 2013] [error] [client 192.168.189.63] PHP Notice:  Undefined variable: centreon_path in /usr/local/centreon/www/include/monitoring/status/TopCounter/xml/ndo/statusCounter.php on line 43, referer: http://192.168.189.36/centreon/main.php?p=604
[Sat Feb 16 18:29:31 2013] [error] [client 192.168.189.63] PHP Warning:  require_once(www/class/centreonXMLBGRequest.class.php): failed to open stream: No such file or directory in /usr/local/centreon/www/include/monitoring/status/TopCounter/xml/ndo/statusCounter.php on line 43, referer: http://192.168.189.36/centreon/main.php?p=604
[Sat Feb 16 18:29:31 2013] [error] [client 192.168.189.63] PHP Fatal error:  require_once(): Failed opening required 'www/class/centreonXMLBGRequest.class.php' (include_path='.:/usr/share/pear:/usr/share/php') in /usr/local/centreon/www/include/monitoring/status/TopCounter/xml/ndo/statusCounter.php on line 43, referer: http://192.168.189.36/centreon/main.php?p=604
[Sat Feb 16 18:33:46 2013] [error] [client 192.168.189.63] PHP Fatal error:  require_once(): Failed opening required 'www/class/centreonXMLBGRequest.class.php' (include_path='.:/usr/share/pear:/usr/share/php') in /usr/local/centreon/www/include/monitoring/status/TopCounter/xml/ndo/statusCounter.php on line 43, referer: http://192.168.189.36/centreon/main.php?p=604

Solution


SELinux blocks httpd to write in any folder other than /var/www/ and some exceptions have to be made.

Configuring SELinux for Centeron 2.4 on CentOS 6.3

yum -y install policycoreutils-python
semanage fcontext -a -t httpd_sys_rw_content_t "/usr/local/centreon(/.*)?"
restorecon -R /usr/local/centreon/
semanage fcontext -a -t httpd_sys_rw_content_t "/etc/centreon(/.*)?"
restorecon -R /etc/centreon
semanage fcontext -a -t httpd_sys_rw_content_t "/usr/local/nagios/var/spool(/.*)?"
semanage fcontext -a -t httpd_sys_content_t "/usr/local/nagios/share(/.*)?"
restorecon -R /usr/local/nagios
semanage fcontext -a -t httpd_sys_content_t "/usr/share/php(/.*)?"
restorecon -R /usr/share/php
semanage fcontext -a -t httpd_sys_content_t "/usr/share/pear(/.*)?"
restorecon -R /usr/share/pear
#

You may want to check out my blog post on Installing Centreon 2.4 on CentOS 6.3 x64.

3 comments:

  1. Thank yooouuu!!!!!! This helped at veri veri much

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. Yap, and for httpd - http://wiki.centos.org/HowTos/SELinux

      Delete