Server setup

Arjen van Bochoven edited this page Nov 10, 2018 · 17 revisions

MunkiReport is a PHP web application, it needs a server that can execute PHP scripts. Setting up a PHP capable webserver is beyond these instructions.

Requirements

  • Starting with MunkiReport version 3, PHP > version 7.0.27 is required.
  • If using MySQL, version 5.7 or higher is recommended.

Source files - download zip archive

  1. Pick or create a directory outside the webroot of the server to install the MunkiReport source files. You don't want the source files to be accessible via the webserver.
  2. Download the zip file from https://github.com/munkireport/munkireport-php/releases/latest (use munkireport-xxx.zip, not Source Code.zip)
  3. Put all files in the directory of step 1

Source files - using git

  1. Pick or create a directory outside the webroot of the server to install the MunkiReport source files. You don't want the source files to be accessible via the webserver.
  2. Use git to checkout the latest version:
git clone https://github.com/munkireport/munkireport-php.git
  1. Install dependencies using composer:
composer install --no-dev --no-suggest

Document root

Now you need to make the public folder accessible to the web. There are a couple of ways to achieve that:

Method 1: set the right document root folder

In your webserver configuration file, set [/path/to/munkireport/public] as the document root.

Pros: this is the easiest and safest method.
Cons: you need to be allowed to choose the document root folder, serving multiple apps from subdirectories is harder

Method 2: create a symbolic link

Using the terminal, create a symbolic in your web directory that points to [/path/to/munkireport/public]

Pros: safe and quite easy and allows you to serve MunkiReport from a subdirectory.
Cons: you need to be able to create symbolic links

Method 3: copy the public folder

You can copy the public folder to the web root and change index.php so it can find the MunkiReport source directory:

In index.php:

define('APP_ROOT', dirname(PUBLIC_ROOT) . '/' );

needs to be changed to

define('APP_ROOT', '/path/to/munkireport/' );

Pros: safe and applicable on most hosting services.
Cons: you will need to do this again when upgrading (files in public may have changed)

After you have setup the document root, you should be able to visit your MunkiReport server with a webbrowser. MunkiReport will complain about a missing config file, but we'll address that in the next section.

Basic configuration

  1. Create config.php in the source directory (next to config_default.php) . Make sure this file starts with <?php and has no whitespace before that, don't add the closing tag for php. config.php overrides the settings in config_default.php. To configure, simply copy relevant settings over from config_default.php to config.php and make the changes in config.php.
  2. Database setup: when using SQLite as backend (which is the default), check if the directory /app/db/ is writeable by the webserver. If you want to use MySQL, check config_default.php for the proper values.

You're done with the server.

Create the first user

  1. Visit the site with a webbrowser, you'll be prompted to create a user and password
  2. Append the generated hash line to config.php
  3. Now refresh the page in your browser, and you should be able to log in with the credentials you just created.
  4. Additional local users may be added by going to http://server/munkireport-php/index.php?/auth/generate and copying the resultant configuration string -- $auth_config['newaccountname'] = '$P$B3n.QBh5pRaJHUBN6MZFNW4JyEjLbE.'; into the config.php file. This is particularly useful when setting up business units.

MunkiReport can be configured with different authentication backends: SAML, AD, LDAP, No Authentication, etc. See Authentication for more info.

Select which modules to install on the client

By default munkireport will only install 2 basic reporting modules: 'machine' and 'reportdata'. If you want the client to report on more items, visit:

http://example.com/index.php?/install/dump_modules/config

Paste the resulting $conf['modules'] = array(...); in your config.php file. Remove items that you don't need reporting on from the array (e.g. 'servermetrics', 'certificate' and 'service' only make sense when installed on a client that runs Mac OSX server).

Descriptions of the Modules.

Advanced server setup

Running MunkiReport from a subdir

Munkireport should able to detect if it is running from a subdirectory. If automatic detection fails, you can also specify the subdirectory in config.php. So if you want to run munkireport from http://munki.mysite.org/report/ add the following to config.php:

$conf['subdirectory'] = '/report/';

A simple Apache .vhost config to get you started

<VirtualHost *:80>
  ServerAdmin webmaster@example.com
  ServerName  munkireport-php.example.com
  ServerAlias munkireport-php.example.com

  AddDefaultCharset utf-8
  DocumentRoot /srv/munkireport-php
    <Directory />
        Options FollowSymLinks
    </Directory>
  LogLevel warn
  CustomLog /var/log/apache2/munkireport-php.example.com-access.log combined
  ErrorLog /var/log/apache2/munkireport-php.example.com-error.log
</VirtualHost>

Running MunkiReport with mod_rewrite

If you're running munkireport on an apache webserver and you want to use mod_rewrite (which gives you nicer urls), you'll have to change the following:

  1. Add $conf['index_page'] = ''; to config.php

NGINX on Ubuntu

Be sure to install these packages: apt-get install php-fpm php-xml php-sqlite3 libcurl3-dev

A Sample location block for NGINX

  location /munkireport-php/ {
    #If you are hosting outside of webroot
    alias /media/Data/munkireport-php/;
    autoindex on;
    location ~* \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_param SCRIPT_FILENAME  /media/Data/$fastcgi_script_name;
      }
  }
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.