Installing Icinga Web 2 with Apache 2.4, Icinga 2 and MySQL on FreeBSD

The last entry was about Installing Icinga 2 with MySQL on FreeBSD This one now shows how to install and configure the new Icinga Web 2 interface on FreeBSD and use it with Icinga 2 and a MySQL database both as authentication and data source.

I assume that you followed the last blog entry and have now a FreeBSD machine running Icinga 2 which writes data into the MySQL database running on the same host.

Install Icinga Web 2 and Apache 2.4 with mod_php

Using binary packages, installing is just a matter of

# pkg install apache24 mod_php56 icingaweb2

The mod_php56 package is automatically enabled in /usr/local/etc/apache24/httpd.conf but it still needs some configuration:

# cat << EOF > /usr/local/etc/apache24/modules.d/001_mod_php.conf
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
DirectoryIndex index.php index.html
<FilesMatch "\.php$">
    SetHandler application/x-httpd-php
<FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source

To enable mod_rewrite in Apache, uncomment the #LoadModue rewrite [...] line:

LoadModule rewrite_module

Copy the example Apache configuration file for Icinga Web 2:

# cp /usr/local/share/examples/icingaweb2/apache/icingaweb2.conf /usr/local/etc/apache24/Includes/

Configure PHP and Include the ZendFramework libaries:

# cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini

In /usr/local/etc/php.ini search for include_path and insert the following after:

include_path = ".:/usr/local/share/ZendFramework/library"

Also in /usr/local/etc/php.ini set date.timezone:

date.timezone = Europe/Berlin

Now enable starting Apache at boot time and start it:

# sysrc apache24_enable=yes
# service apache24 start

Configure Icinga Web 2

You can either configure Icinga Web 2 and MySQL from the command line or more comfortable trough its web interface. I will show you the latter:

Create a new setup token:

# cd /usr/local/www/icingaweb2/
# ./bin/icingacli setup token create --config=/usr/local/etc/icingaweb2
The newly generated setup token is: 4fa15561c827adc1

With the token you created, go to http://$server_ip/icingaweb2/setup and paste the token into the text field.

Setup token

Then select at least the Monitoring module:

Module selection

You should not see any red components:


Select Database as authentication method:


In this screen, enter icingaweb2 as the database name, root as username and the root password you set in the previous blog entry.

Database Resource

Set icingaweb2 as authentication backend:

Authentication backend

Setup a new user. I use icingaadmin for the example:


Save your user preferences in the database and log to syslog:

Application configuration

Check if the configuration is right:


Now configure the monitoring module:

Monitoring module

Select IDO as backend type:

Monitoring backend

As IDO Resource enter localhost as hostname icinga as database name, icinga as username and the according password in the MySQL database.

Monitoring IDO resource

To send commands to the Icinga 2 process like re-scheduling, etc. point the command file to /var/run/icinga2/cmd/icinga2.cmd.

Command transport

To protect passwords from the web interface, leave the defaults in this screen:

Monitoring Security

Have a last look at the settings:


And that’s it, enjoy Icinga Web 2!

Icinga Web 2