{"id":937,"date":"2019-08-02T13:15:06","date_gmt":"2019-08-02T13:15:06","guid":{"rendered":"https:\/\/www.web-workers.ch\/?p=937"},"modified":"2021-11-22T08:26:25","modified_gmt":"2021-11-22T07:26:25","slug":"how-to-install-icinga-2-and-icinga-web-2-on-centos-7-2","status":"publish","type":"post","link":"https:\/\/www.web-workers.ch\/index.php\/2019\/08\/02\/how-to-install-icinga-2-and-icinga-web-2-on-centos-7-2\/","title":{"rendered":"How to install Icinga 2 and Icinga Web 2 on CentOS 7"},"content":{"rendered":"<h4>Requirements<\/h4>\n<ul>\n<li>Install a fresh CentOS 7 (1810)<\/li>\n<li>This tutorial requires <a href=\"https:\/\/www.google.com\/search?q=CentOS+7+disable+SELinux\" target=\"_blank\" rel=\"noopener noreferrer\">SELinux to be disabled<\/a>. In case you need to use SELinux, please read the appendix at the end of the page.<\/li>\n<\/ul>\n<h4>Preparations<\/h4>\n<p>Update your current installation and reboot your host<\/p>\n<p><code># yum -y update<\/p>\n<h1>reboot<\/code><\/h1>\n<p>Install the EPEL repository<\/p>\n<p><code># yum -y install epel-release<\/code><\/p>\n<h4>Install OpenSSL<\/h4>\n<p><code># yum -y install openssl*<\/code><\/p>\n<h4>Install Apache<\/h4>\n<p>Install apache using yum:<\/p>\n<p><code># yum -y install httpd*<\/p>\n<h1>yum -y install mod_ssl<\/code><\/h1>\n<p>Remove the predefined welcome page:<\/p>\n<p><code># sed -i 's\/^\/#&amp;\/g' \/etc\/httpd\/conf.d\/welcome.conf<\/code><br \/>\nForbid Apache from exposing files and directories within the web root directory \/var\/www\/html to visitors:<\/p>\n<p><code># sed -i \"s\/Options Indexes FollowSymLinks\/Options FollowSymLinks\/\" \/etc\/httpd\/conf\/httpd.conf<\/code><br \/>\nStart the Apache service and get it started on boot:<\/p>\n<p><code># systemctl start httpd.service<\/p>\n<h1>systemctl enable httpd.service<\/code><\/h1>\n<h4>Install MariaDB<\/h4>\n<p>Install MariaDB using yum:<\/p>\n<p><code># yum -y install mariadb*<\/code><br \/>\nStart the MariaDB service:<\/p>\n<p><code># systemctl start mariadb.service<\/p>\n<h1>systemctl enable mariadb.service<\/code><\/h1>\n<p>Secure the installation of MariaDB:<\/p>\n<p><code># \/usr\/bin\/mysql_secure_installation<\/code><br \/>\nDuring the process, answer questions on the screen as below:<\/p>\n<p><code>Enter current password for root (enter for none): Enter<br \/>\nSet root password? [Y\/n]: Y<br \/>\nNew password: &lt;your-password&gt;<br \/>\nRe-enter new password: &lt;your-password&gt;<br \/>\nRemove anonymous users? [Y\/n]: Y<br \/>\nDisallow root login remotely? [Y\/n]: Y<br \/>\nRemove test database and access to it? [Y\/n]: Y<br \/>\nReload privilege tables now? [Y\/n]: Y<\/code><\/p>\n<h4>Install PHP<\/h4>\n<p>Install PHP and necessary PHP extensions as required by Icinga 2 and Icinga Web 2:<\/p>\n<p>Sidenote: Please read the comment of Michael Friedrich before you do the php installation.<br \/>\n<a href=\"https:\/\/www.web-workers.ch\/index.php\/2019\/08\/02\/how-to-install-icinga-2-and-icinga-web-2-on-centos-7-2\/2021-07-15-16_58_23-thuinformatik-auf-twitter_-_how-to-install-icinga-2-and-icinga-web-2-on-centos-7\/\" rel=\"attachment wp-att-1335\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1335\" data-permalink=\"https:\/\/www.web-workers.ch\/index.php\/2019\/08\/02\/how-to-install-icinga-2-and-icinga-web-2-on-centos-7-2\/2021-07-15-16_58_23-thuinformatik-auf-twitter_-_how-to-install-icinga-2-and-icinga-web-2-on-centos-7\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.web-workers.ch\/wp-content\/uploads\/2019\/08\/2021-07-15-16_58_23-thuinformatik-auf-Twitter_-_How-to-install-Icinga-2-and-Icinga-Web-2-on-CentOS-7.png?fit=585%2C182&amp;ssl=1\" data-orig-size=\"585,182\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"2021-07-15 16_58_23-thuinformatik auf Twitter_ _How to install Icinga 2 and Icinga Web 2 on CentOS\u00a07\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.web-workers.ch\/wp-content\/uploads\/2019\/08\/2021-07-15-16_58_23-thuinformatik-auf-Twitter_-_How-to-install-Icinga-2-and-Icinga-Web-2-on-CentOS-7.png?fit=585%2C182&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.web-workers.ch\/wp-content\/uploads\/2019\/08\/2021-07-15-16_58_23-thuinformatik-auf-Twitter_-_How-to-install-Icinga-2-and-Icinga-Web-2-on-CentOS-7.png?resize=585%2C182&#038;ssl=1\" alt=\"\" width=\"585\" height=\"182\" class=\"alignnone wp-image-1335 size-full\" srcset=\"https:\/\/i0.wp.com\/www.web-workers.ch\/wp-content\/uploads\/2019\/08\/2021-07-15-16_58_23-thuinformatik-auf-Twitter_-_How-to-install-Icinga-2-and-Icinga-Web-2-on-CentOS-7.png?w=585&amp;ssl=1 585w, https:\/\/i0.wp.com\/www.web-workers.ch\/wp-content\/uploads\/2019\/08\/2021-07-15-16_58_23-thuinformatik-auf-Twitter_-_How-to-install-Icinga-2-and-Icinga-Web-2-on-CentOS-7.png?resize=300%2C93&amp;ssl=1 300w\" sizes=\"auto, (max-width: 585px) 100vw, 585px\" \/><\/a><\/p>\n<p><code># yum -y install php php-gd php-intl php-ldap php-ZendFramework php-ZendFramework-Db-Adapter-Pdo-Mysql<\/code><br \/>\nSet the proper timezone for your machine, which can be determined <a href=\"https:\/\/www.php.net\/manual\/en\/timezones.php\" target=\"_blank\" rel=\"noopener noreferrer\">from the PHP official website<\/a>. On my server instance, the timezone value is &#8220;Europe\/Zurich&#8221;. Open the PHP configuration file with the vi editor:<\/p>\n<p><code># vi \/etc\/php.ini<\/code><\/p>\n<p>Find the line:<br \/>\n; date.timezone =<\/p>\n<p>Change it to:<\/p>\n<p><code>date.timezone = America\/Los_Angeles<\/code><br \/>\nSave and quit (:x!)<\/p>\n<p>Restart the Apache service in order to put new configurations into effect:<\/p>\n<p><code># systemctl restart httpd.service<\/code><\/p>\n<h4>Install Icinga2 and it&#8217;s plugins<\/h4>\n<p>Install Icinga 2 and its plugins using the icinga repo:<\/p>\n<p><code># rpm --import http:\/\/packages.icinga.org\/icinga.key<\/p>\n<h1>yum -y install https:\/\/packages.icinga.com\/epel\/icinga-rpm-release-7-latest.noarch.rpm<\/h1>\n<h1>yum -y install icinga2 nagios-plugins-all<\/code><\/h1>\n<p>You can learn more about these plugins from the <a href=\"https:\/\/www.monitoring-plugins.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">Monitoring Plugins Project<\/a>.<\/p>\n<p>Start and enable on boot the Icinga 2 service:<\/p>\n<p><code># systemctl start icinga2.service<\/p>\n<h1>systemctl enable icinga2.service<\/code><\/h1>\n<p>By default, the Icinga 2 program will enable three features: checker, mainlog, and notification. You can verify that using the following command:<\/p>\n<p><code># icinga2 feature list<\/code><\/p>\n<h4>Setup the Icinga 2 IDO modules<\/h4>\n<p>Install the IDO (Icinga Data Output) modules for MySQL<\/p>\n<p><code># yum -y install icinga2-ido-mysql<\/code><\/p>\n<p>Create a database for Icinga 2. log into the MySQL shell as root:<\/p>\n<p><code># mysql -u root -p<\/code><\/p>\n<p>Use the MariaDB root password you set before to log in.<\/p>\n<p>Create a database named &#8220;icinga&#8221; and a database user named icinga with the password icinga, and then grant privileges on this database to this database user.<\/p>\n<p><code>CREATE DATABASE icinga;<br \/>\nGRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icinga.* TO 'icinga'@'localhost' IDENTIFIED BY 'icinga';<br \/>\nFLUSH PRIVILEGES;<br \/>\nEXIT;<\/code><\/p>\n<p>Import the Icinga 2 IDO schema<\/p>\n<p><code># mysql -u root -p icinga &lt; \/usr\/share\/icinga2-ido-mysql\/schema\/mysql.sql<\/code><\/p>\n<p>When prompted, input the MariaDB root password to finish the job.<\/p>\n<p>Enable the IDO MySQL module<\/p>\n<p><code># vi \/etc\/icinga2\/features-available\/ido-mysql.conf<\/code><\/p>\n<p>Find these lines:<\/p>\n<p><code>\/\/user = \"icinga\"<br \/>\n\/\/password = \"icinga\"<br \/>\n\/\/host = \"localhost\"<br \/>\n\/\/database = \"icinga\"<\/code><br \/>\nuncomment them as below:<\/p>\n<p><code>user = \"icinga\"<br \/>\npassword = \"icinga\"<br \/>\nhost = \"localhost\"<br \/>\ndatabase = \"icinga\"<\/code><br \/>\nSave and quit (:x!)<\/p>\n<p>Enable the ido-mysql feature and restart icigina2:<\/p>\n<p><code># icinga2 feature enable ido-mysql<\/p>\n<h1>systemctl restart icinga2.service<\/code><\/h1>\n<h4>Install Icinga Web 2<\/h4>\n<p>Setup external command pipe<\/p>\n<p><code># icinga2 feature enable command<\/p>\n<h1>systemctl restart icinga2.service<\/code><\/h1>\n<p>Before you can send commands to Icinga 2 using a web interface, you need to add the &#8220;apache&#8221; user to the icingacmd group:<\/p>\n<p><code># usermod -a -G icingacmd apache<\/code><\/p>\n<p>You can verify your modification using the following command:<\/p>\n<p><code># id apache<\/code><\/p>\n<p>Since version 2.5.0 we also require a\u00a0<strong>newer PHP version<\/strong>\u00a0than what is available in RedHat itself. You need to enable the SCL repository, so that the dependencies can pull in the newer PHP.<\/p>\n<p><code># yum -y install centos-release-scl<\/code><\/p>\n<p>Install the icingaweb2 and icingacli RPM packages<\/p>\n<p><code># yum -y install icingaweb2 icingacli<\/code><\/p>\n<p>Point the Apache web root directory to the location of Icinga Web 2:<\/p>\n<p><code># icingacli setup config webserver apache --document-root \/usr\/share\/icingaweb2\/public<\/p>\n<h1>systemctl restart httpd.service<\/code><\/h1>\n<h4>Setting up FPM<\/h4>\n<p>On CentOS you want to run Icinga Web 2 with PHP-FPM instead of the Apache module. The default pool www should be sufficient for Icinga Web 2.<\/p>\n<p><code># systemctl start rh-php71-php-fpm.service<\/p>\n<h1>systemctl enable rh-php71-php-fpm.service<\/code><\/h1>\n<p>All module packages for PHP have this SCL prefix, so you can install a database module like this:<\/p>\n<p><code># yum install rh-php71-php-mysqlnd<\/code><\/p>\n<h4>Add a few missing features<\/h4>\n<p>Installing ImageMagick from Repository<\/p>\n<p>First, install following prerequisite php-pear, php-devel and gcc packages to compile imagick PHP extension.<\/p>\n<p><code># yum -y install php-pear php-devel gcc<\/code><\/p>\n<p>Once you\u2019ve installed php-pear, php-devel and gcc packages, you may now install ImageMagick software for PHP and Perl support using yum command.<\/p>\n<p><code># yum -y install ImageMagick ImageMagick-devel ImageMagick-perl<\/p>\n<h1>yum -y install sclo-php71-php-pecl-imagick<\/code><\/h1>\n<p>Next, verify that ImageMagick has been installed on your system by checking its version.<\/p>\n<p><code># convert --version<br \/>\nVersion: ImageMagick 6.7.8-9 2019-02-01 Q16 http:\/\/www.imagemagick.org<br \/>\nCopyright: Copyright (C) 1999-2012 ImageMagick Studio LLC<br \/>\nFeatures: OpenMP    <\/code><\/p>\n<p>Then restart tje FPM service:<\/p>\n<p><code>systemctl restart rh-php71-php-fpm.service<\/code><\/p>\n<h4>First time launch of Icinga Web 2 configuration<\/h4>\n<p>Generate a setup token for later use in the web interface:<\/p>\n<p><code>icingacli setup token create<\/code><\/p>\n<p>Initiate the Icinga 2 installation wizard in the web interface. Point your web browser to the following URL:<\/p>\n<p><code>http:\/\/&lt;your-server-ip&gt;\/icingaweb2\/setup<\/code><\/p>\n<p>On the Welcome page, input the setup token you generated earlier, and then click the &#8220;Next&#8221; button.<\/p>\n<p>On the Modules page, select modules you want to enable (at least, the Monitoring module is required), and then click the &#8220;Next&#8221; button.<\/p>\n<p>On the Requirements page, make sure that every requirement item is satisfied, and then click the &#8220;Next&#8221; button.<\/p>\n<p>On the Authentication page, you need to choose the authentication method when accessing Icinga Web 2. Here, you can choose Database, and then click the &#8220;Next&#8221; button.<\/p>\n<p>On the Database Resource page, fill out all required fields as below, and then click the &#8220;Next&#8221; button.<\/p>\n<pre>Resource Name*: icingaweb_db\nDatabase Type*: MySQL\nHost*: localhost\nDatabase Name*: icingaweb2\nUsername*: root\nPassword*: &lt;MariaDB-root-password&gt;<\/pre>\n<p>On the Authentication Backend page, using the default backend name <span style=\"color: #ff0000;\"><em>icingaweb2<\/em><\/span>, click the Next button to move on.<\/p>\n<p>On the Administration page, setup the first Icinga Web 2 administrative account (for example: admin) and password (&lt;mypassword&gt;), and then click the &#8220;Next&#8221; button.<\/p>\n<p>On the Application Configuration page, you can adjust application- and logging-related configuration options to fit your needs. For now, you can use the default values listed below and click the &#8220;Next&#8221; button to proceed.<\/p>\n<pre>Show Stacktraces: Checked\nUser Preference Storage Type*: Database\nLogging Type*: Syslog\nLogging Level*: Error\nApplication Prefix*: icingaweb2\n<\/pre>\n<p>On the Review page, double check your configuration, and then click the Next button.<\/p>\n<p>On the Monitoring Module Configuration Welcome page, click the Next button.<\/p>\n<p>On the Monitoring Backend page, use the default backend name <em><span style=\"color: #ff0000;\">icinga<\/span> <\/em>and backend type <span style=\"color: #ff0000;\"><em>IDO<\/em><\/span>, and then click the &#8220;Next&#8221; button.<\/p>\n<p>On the Monitoring IDO Resource page, input IDO database details you setup earlier, and then click the &#8220;Next&#8221; button.<\/p>\n<pre>Resource Name*: icinga_ido\nDatabase Type*: MySQL\nHost*: localhost\nDatabase Name*: icinga\nUsername*: icinga\nPassword*: icinga<\/pre>\n<p>On the Command Transport page, still use these default values listed below. Click the Next button to move on.<\/p>\n<pre>Transport Name*: icinga2\nTransport Type*: Local Command File\nCommand File*: \/var\/run\/icinga2\/cmd\/icinga2.cmd<\/pre>\n<p>7.19) On the Monitoring Security page, still use the default value:<\/p>\n<p><code>Protected Custom Variables: *pw*,*pass*,community<\/code><\/p>\n<p>Click the &#8220;Next&#8221; button to go to next page.<\/p>\n<p>On the review page, double check your configuration, and then click the Finish button.<\/p>\n<p>7.21) On the Congratulations! page, click the <em><span style=\"color: #ff0000;\">Login to Icinga Web 2<\/span><\/em> link to jump to the Icinga Web 2 login page. Use the Icinga Web 2 administrative account and password you setup earlier to log in.<\/p>\n<p>That concludes our tutorial. Thank you for reading.<\/p>\n<p>We used inputs from following websites:<br \/>\n<a href=\"https:\/\/www.vultr.com\/docs\/how-to-install-icinga-2-and-icinga-web-2-on-centos-7\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/www.vultr.com\/docs\/how-to-install-icinga-2-and-icinga-web-2-on-centos-7<\/a><br \/>\n<a href=\"https:\/\/techgoat.net\/index.php?id=115\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/techgoat.net\/index.php?id=115<\/a><br \/>\n<a href=\"https:\/\/www.tecmint.com\/install-imagemagick-in-linux\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/www.tecmint.com\/install-imagemagick-in-linux\/<\/a><br \/>\n<a href=\"https:\/\/icinga.com\/docs\/icingaweb2\/latest\/doc\/02-Installation\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/icinga.com\/docs\/icingaweb2\/latest\/doc\/02-Installation\/<\/a><\/p>\n<h4>Appendix: SELinux notes<\/h4>\n<p>In case you want\/need to use SELinux, you have the possibility to install the package &#8220;icinga2-selinux&#8221;, afterwards you can apply the policy package by using audit2allow.<\/p>\n<p><code># yum -y install icinga2-selinux<\/p>\n<h1>audit2allo -a -M icingaweb2<\/h1>\n<h1>semodule -i icingaweb2.pp<\/code><\/h1>\n","protected":false},"excerpt":{"rendered":"<p>Requirements Install a fresh CentOS 7 (1810) This tutorial requires SELinux to be disabled. In case you need to use SELinux, please read the appendix at the end of the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":919,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4],"tags":[],"class_list":["post-937","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.web-workers.ch\/wp-content\/uploads\/2019\/08\/Icinga_logo.png?fit=800%2C289&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8sxjX-f7","jetpack-related-posts":[],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/posts\/937","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/comments?post=937"}],"version-history":[{"count":5,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/posts\/937\/revisions"}],"predecessor-version":[{"id":1483,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/posts\/937\/revisions\/1483"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/media\/919"}],"wp:attachment":[{"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/media?parent=937"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/categories?post=937"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/tags?post=937"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}