Failed to set up Icinga Web 2

Hello guys,
I tried to install Icinga web 2 in CentOS, I got this error

Successfully connected to existing database "icingaweb2"...
Database schema already exists...
Login "root" already exists...
Required privileges were already granted to login "root".
The database has been fully set up!

General configuration could not be written to: /etc/icingaweb2/config.ini. An error occured:
ERROR: RuntimeException in /usr/share/php/Icinga/Util/File.php:39 with message: SplFileObject::__construct(/etc/icingaweb2/config.ini): failed to open stream: Permission denied

Authentication configuration could not be written to: /etc/icingaweb2/authentication.ini. An error occured:
ERROR: RuntimeException in /usr/share/php/Icinga/Util/File.php:39 with message: SplFileObject::__construct(/etc/icingaweb2/authentication.ini): failed to open stream: Permission denied
Unable to define account "icingaweb2admin" as initial administrator. An error occured:
ERROR: RuntimeException in /usr/share/php/Icinga/Util/File.php:39 with message: SplFileObject::__construct(/etc/icingaweb2/roles.ini): failed to open stream: Permission denied

User Group Backend configuration could not be written to: /etc/icingaweb2/groups.ini. An error occured:
ERROR: RuntimeException in /usr/share/php/Icinga/Util/File.php:39 with message: SplFileObject::__construct(/etc/icingaweb2/groups.ini): failed to open stream: Permission denied

Resource configuration could not be written to: /etc/icingaweb2/resources.ini. An error occured:
ERROR: RuntimeException in /usr/share/php/Icinga/Util/File.php:39 with message: SplFileObject::__construct(/etc/icingaweb2/resources.ini): failed to open stream: Permission denied

Monitoring backend configuration could not be written to: /etc/icingaweb2/modules/monitoring/backends.ini. An error occured:
ERROR: RuntimeException in /usr/share/php/Icinga/Util/File.php:97 with message: Failed to create missing directory "/etc/icingaweb2/modules/monitoring/" (mkdir(): Permission denied)
Resource configuration could not be udpated: /etc/icingaweb2/resources.ini. An error occured:
ERROR: RuntimeException in /usr/share/php/Icinga/Util/File.php:39 with message: SplFileObject::__construct(/etc/icingaweb2/resources.ini): failed to open stream: Permission denied

Command transport configuration could not be written to: /etc/icingaweb2/modules/monitoring/commandtransports.ini. An error occured:
ERROR: RuntimeException in /usr/share/php/Icinga/Util/File.php:97 with message: Failed to create missing directory "/etc/icingaweb2/modules/monitoring/" (mkdir(): Permission denied)

Monitoring security configuration could not be written to: /etc/icingaweb2/modules/monitoring/config.ini. An error occured:
ERROR: RuntimeException in /usr/share/php/Icinga/Util/File.php:97 with message: Failed to create missing directory "/etc/icingaweb2/modules/monitoring/" (mkdir(): Permission denied)

Module "monitoring" could not be enabled. An error occured:
ERROR: Icinga\Exception\SystemPermissionException in /usr/share/php/Icinga/Application/Modules/Manager.php:269 with message: Failed to create enabledModules directory "/etc/icingaweb2/enabledModules" (mkdir(): Permission denied)

Can you guys help me to know the issue here,
Thank’s in advance.

looks like icingaweb2 has no access to /etc/icingaweb2 check the permissions

what is the permission that should be there ?

They should look like this:

drwxrws---   5 root     icingaweb2  4096 Mär 13  2018 ./
drwxr-xr-x 135 root     root       12288 Mai 15 07:04 ../
-rw-rw-r--   1 www-data icingaweb2   286 Aug 13  2018 authentication.ini
-rw-rw-r--   1 www-data icingaweb2   276 Mär 15  2018 config.ini
drwxrwsr--   3 www-data icingaweb2  4096 Jul 14  2017 dashboards/
drwxr-sr--   2 www-data icingaweb2  4096 Mär  4 08:50 enabledModules/
-rw-rw-r--   1 www-data icingaweb2    54 Apr  3  2017 groups.ini
drwxrws---   9 root     icingaweb2  4096 Nov 26 07:15 modules/
-rw-rw-r--   1 www-data icingaweb2  1162 Nov 26 07:15 resources.ini
-rw-rw-r--   1 www-data icingaweb2   733 Mär 12 13:55 roles.ini

1 Like

Hi,

either install the icingaweb2-selinux package receiving the proper policies or set SELinux to permissive.

Cheers,
Michael

1 Like

it worked, thank you :slight_smile:

I also have something like that:

Failed to insert. An error occurred: file_put_contents(/etc/icingaweb2/roles.ini): failed to open stream: Permission denied

  • CentOS 7
  • Kernel version: 3.10.0-1160.42.2.el7.x86_64
  • Icinga Web 2 2.9.3
  • Git Commit c757a17530c326c7d6daebd6171486cb8167a8a1
  • PHP Version 7.3.29
  • Apache/2.4.6 (CentOS)
  • PHP 7.3.29 (fpm-fcgi) (built: Aug 3 2021 12:27:51)
    Copyright (c) 1997-2018 The PHP Group
    Zend Engine v3.3.29, Copyright (c) 1998-2018 Zend Technologies
  • MODULE VERSION
    • setup 2.9.3
    • audit 1.0.1
    • director 1.8.1
    • doc 2.9.3
    • fileshipper 1.2.0
    • incubator 0.6.0
    • ipl v0.5.0
    • monitoring 2.9.3
ls -alh /etc/icingaweb2/
total 48K
drwxrws---   4 root icingaweb2 4.0K Sep 14 12:56 .
drwxr-xr-x. 91 root root        12K Sep 14 09:52 ..
-rw-r--r--   1 root icingaweb2   52 Sep 14 08:53 authentication.ini
-rw-r--r--   1 root icingaweb2  363 Sep 14 08:53 config.ini
drwxr-s---   2 root icingaweb2 4.0K Sep 14 10:25 enabledModules
-rw-r--r--   1 root icingaweb2   52 Sep 14 08:54 groups.ini
drwxrws---   8 root icingaweb2 4.0K Sep 14 11:13 modules
-rw-r--r--   1 root icingaweb2  874 Sep 14 09:47 resources.ini
-rw-r--r--   1 root icingaweb2   78 Sep 14 08:53 roles.ini
-rw-rw----   1 root icingaweb2   16 Sep 14 08:42 setup.token
yum install icingaweb2-selinux
Package icingaweb2-selinux-2.9.3-1.el7.icinga.noarch already installed and latest version
Nothing to do
sestatus 
SELinux status:                 disabled

The problem was solved when I ran:

chown -R apache:icingaweb2 /etc/icingaweb2/
ls -alh /etc/icingaweb2/
total 48K
drwxrws---   4 apache icingaweb2 4.0K Sep 14 13:01 .
drwxr-xr-x. 91 root   root        12K Sep 14 13:14 ..
-rw-r--r--   1 apache icingaweb2   52 Sep 14 08:53 authentication.ini
-rw-r--r--   1 apache icingaweb2  363 Sep 14 08:53 config.ini
drwxr-s---   2 apache icingaweb2 4.0K Sep 14 10:25 enabledModules
-rw-r--r--   1 apache icingaweb2   52 Sep 14 08:54 groups.ini
drwxrws---   8 apache icingaweb2 4.0K Sep 14 11:13 modules
-rw-r--r--   1 apache icingaweb2  874 Sep 14 09:47 resources.ini
-rw-r--r--   1 apache icingaweb2   78 Sep 14 08:53 roles.ini
-rw-rw----   1 apache icingaweb2   16 Sep 14 08:42 setup.token
1 Like