Fork me on GitHub
Monitorix logo
Celebrating 10 years :: 2005-2015

Welcome to The Monitorix Project

Take control over your small server

Installation on a FreeBSD 9-STABLE with Nginx + FastCGI

WARNING: for 2.x branch only (OBSOLETE)

Many thanks to Darryl Yeoh Gim Hong for sending me the following HOWTO:
#
# Installing Monitorix on FreeBSD 9-STABLE/amd64 with Nginx + php-fpm + fcgiwrap
#
# Main Webpage: http://www.monitorix.org/
# Documentation: http://www.monitorix.org/documentation.html
#
# Guide written by Darryl Yeoh <drl@bsd.my>
#
# NOTE: This howto is in no way perfect. It was written base on memory. If you get into
# trouble while following this howto, feel free to drop me a mail about it and I will
# update this howto again.
#
# $LOG_FILE = '/var/log/monitorix' <- This would be the 1st place to look at if you run into trouble.

The steps below needs to be run as the user root. Either 'su -' or 'sudo -s' to switch to root.

# BEGIN

Assuming the following packages are already installed:-

  ruby1.8
  portupgrade
  perl5.12
  python2.7
  php5.3 w/ FPM option (Experimental)

If these aren't installed, install them now :>

# PRE INSTALLATION

1. Updating ports tree

  cp /usr/share/examples/cvsup/ports-supfile /root

  [Edit parameters in ports-supfile]

  csup -g -L2 /root/ports-supfile


2. Update ports INDEX file

  portsdb -Fu


3. Installing packages
    
  portinstall www/nginx www/fcgiwrap sysutils/monitorix \
  databases/p5-DBI databases/p5-DBD-mysql databases/rrdtool \
  databases/p5-RRD-Simple net/p5-Socket devel/p5-Getopt-Long \
  www/p5-LWP-UserAgent-POE textproc/p5-XML-Simple

Btw you might want to take a look at http://www.monitorix.org/installation.html and scroll right to
the bottom for Requirements.


# POST INSTALLATION

1. Monitorix

By default, the installation installs monitorix.cgi into /usr/local/www/cgi-bin/. In my setup,
I copied this file to /usr/local/www/monitorix/cgi-bin/ instead keeping it all in one place.

  mkdir /usr/local/www/monitorix/{cgi-bin,logs}
  mkdir -p /var/db/rrd/monitorix
  cp /usr/local/www/cgi-bin/monitorix.cgi /usr/local/www/monitorix/cgi-bin/
  chmod 0555 /usr/local/www/monitorix/cgi-bin/monitorix.cgi

The config file is /usr/local/etc/monitorix.conf. Edit this file to your desire. The key thing
in this file are:

  our $TITLE = "Server Stats";
  our $HOSTNAME = "monitorix.example.com";
  our $THEME_COLOR = "black";
  our $REFRESH_RATE = "150";
  our $IFACE_MODE = "graph";
  our $ENABLE_ZOOM = "Y";
  our $NETSTATS_IN_BPS = "N";

  our $BASE_DIR = "/usr/local/www/monitorix/";
  our $BASE_LIB = "/var/db/rrd/monitorix/";
  our $BASE_URL = "/";
  our $BASE_CGI = "/cgi-bin/";


2. Nginx w/ fcgiwrap

Edit /usr/local/etc/nginx/nginx.conf or a custom.conf to look like this

  http {
      [...]

  ## Monitorix Server block(VirtualHosts)

    server {

      listen 192.168.1.10:80;
      #listen [2001:db8:ffff:1::10]:80;
      server_name monitorix.example.com;
      root /usr/local/www/monitorix;

      error_log /usr/local/www/monitorix/logs/error.log;
      access_log /usr/local/www/monitorix/logs/access.log;
      log_not_found off;

      location /cgi-bin/ {
	gzip off;
	root /usr/local/www/monitorix;
	include /usr/local/etc/nginx/fastcgi_params;
	fastcgi_pass unix:/tmp/fcgiwrap.socket;
	fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      }
    }
  }


3. rc.conf

/etc/rc.conf should have the following

    nginx_enable="YES"
    monitorix_enable="YES"
    php_fpm_enable="YES"
    fcgiwrap_enable="YES"
    fcgiwrap_profiles="main"
    fcgiwrap_main_socket="unix:/tmp/fcgiwrap.socket"
    fcgiwrap_main_user="www"


4. Start the services

    /usr/local/etc/rc.d/fcgiwrap start
    /usr/local/etc/rc.d/php-fpm start
    /usr/local/etc/rc.d/nginx start
    /usr/local/etc/rc.d/monitorix start


Finally open your browser and goto > http://monitorix.example.com/

Click the 'Ok' button and you should start seeing your graphs.

# END