How To Setup Icinga Web 2 on CentOS 7 / RHEL 7
This post covers the installation of Icinga web 2, a web interface for Icinga 2 where you monitor your whole infrastructure in single place.
Article Series
1: How To Install Icinga 2 on CentOS 7 / RHEL 7
2: How To Setup Icinga Web 2 on CentOS 7 / RHEL 7
3: How To Add Remote Linux Machines into Icinga 2 Monitoring Tool
This guide explains you to setup Icinga 2 with Icinga web 2. We can install Icinga web 2 either using an official repository or from source depending on the operating system.
Requirements
- A web server, e.g., Apache or Nginx
- PHP 5.6.0 and above with cURL, gettext, intl, mbstring, OpenSSL, and XML support.
- PHP LDAP library when using LDAP or Active Directory authentication.
- PHP libraries for MySQL or PostgreSQL
Install PHP and PHP Extensions
As said in the requirements, Icinga Web 2 requires PHP version 5.6 and above. The PHP version you need for Icinga web 2 is higher than what is available on CentOS / Redhat base repositories. So, you would need to enable SCL repository and rhel-server-rhscl-7-rpms repository on CentOS and RHEL respectively.
### CentOS 7 ### yum install -y centos-release-scl ### RHEL 7 ### subscription-manager repos --enable rhel-7-server-optional-rpms subscription-manager repos --enable rhel-server-rhscl-7-rpms
Install the PHP package and extensions for Icinga Web 2.
### CentOS 7 ### yum -y install rh-php71-php-json rh-php71-php-pgsql rh-php71-php-xml rh-php71-php-intl rh-php71-php-common rh-php71-php-pdo rh-php71-php-mysqlnd rh-php71-php-cli rh-php71-php-mbstring rh-php71-php-fpm rh-php71-php-gd rh-php71-php-zip rh-php71-php-ldap rh-php71-php-imagick ### RHEL 7 ### yum -y install rh-php71-php-json rh-php71-php-pgsql rh-php71-php-xml rh-php71-php-intl rh-php71-php-common rh-php71-php-pdo rh-php71-php-mysqlnd rh-php71-php-cli rh-php71-php-mbstring rh-php71-php-fpm rh-php71-php-gd rh-php71-php-zip rh-php71-php-ldap
Configure the time zone in the php.ini file.
vi /etc/opt/rh/rh-php71/php.ini
Look for the below line and update it with your timezone.
date.timezone = US/Central
Restart the PHP-FPM service.
systemctl restart rh-php71-php-fpm
Enable PHP-FPM service to start automatically at system boot.
systemctl enable rh-php71-php-fpm
Add Icinga 2 Repository
Add Icinga 2 repository on your system in case if you haven’t already set up.
rpm --import https://packages.icinga.com/icinga.key yum install https://packages.icinga.com/epel/icinga-rpm-release-7-latest.noarch.rpm
Install Icinga Web 2
Use the yum command on CentOS/RHEL to install the Icinga Web 2 package along with Icinga CLI and Apache web server.
yum -y install icingaweb2 icingacli httpd
Enable the Apache service to start automatically at the system startup.
systemctl enable httpd
SELinux
If you are running Icinga Web 2 with SELinux enabled, then consider installing the below package to set policy for Icinga Web 2.
yum -y install icingaweb2-selinux
Firewall
Run the below commands to allow HTTP traffic to access Icinga Web 2 from external machines.
firewall-cmd --permanent --add-service=http firewall-cmd --reload
Preparing Icinga Web 2 Setup
Icinga CLI is used for performing administration tasks in the command line. Both Icinga Web 2 and CLI must have access to logs and configurations. Add web server user (apache to the system group (icingaweb2)
groupadd -r icingaweb2 usermod -a -G icingaweb2 apache
Create the Icinga Web 2 configuration directory.
icingacli setup config directory --group icingaweb2
Restart both Apache and PHP-FPM services.
systemctl restart httpd systemctl restart rh-php71-php-fpm
Icinga Web 2 Setup Wizard
When you are visiting Icinga Web 2 for the first time, Icinga web setup wizard will guide you through all the steps for the successful installation of Icinga Web 2.
For security reason, you would need to generate the token for the Icinga Web 2 installation.
Generate the token using the following command.
icingacli setup token create
Output:
The newly generated setup token is: 04fa4ea1baf4f0b9
Copy and paste the generated token on the setup page and click Next.
