Install from source on Debian

This details what the Debian package does for you automatically. Adapt this if you can’t use an official .deb or need to install on something that isn’t Debian-based.

Note

This howto is based on Debian 9 (Stretch).

1. OS dependencies

First get the following OS packages:

apt-get install -y python-pip python-wheel git postgresql apache2 libapache2-mod-wsgi libsnmp30

2. Get the source

Get the source:

git clone https://github.com/Uninett/nav.git
cd nav

You might want to choose your version now, otherwise you’ll be installing the bleeding edge master branch. All release versions have git tags, so you can easily find and checkout the latest stable version (although these instructions are not valid for versions of NAV prior to 4.9).

4. Install NAV itself

pip install .
nav config install /etc/nav

The configuration files are now found in /etc/nav/. Verify that NAV can actually find nav.conf:

nav config where

5. Build the docs

If you like, you can build the complete HTML documentation thus:

python setup.py build_sphinx

6. Initialize the database

In /etc/nav/db.conf there should be an option called userpw_nav. Choose a password and append it here, then run:

sudo -u postgres navsyncdb -c

You should now have a database nav with a user nav.

7. Create users and groups

Create a navcron user and a corresponding group for NAV to run as:

sudo addgroup --system nav
sudo adduser --system --home /usr/share/nav \
             --shell /bin/sh --ingroup nav navcron

You should also make sure navcron has permission to write log files, pid files and various other state information. You can configure the log and pid file directories in nav.conf. Then make sure these directories exist and are writable for the navcron user:

sudo chown -R navcron:nav /path/to/log/directory
sudo chown -R navcron:nav /path/to/pid/directory

Sending SMS messages using a locally attached GSM device

If you want to use NAV’s SMS functionality in conjunction with Gammu, you should make sure the navcron user is allowed to write to the serial device you’ve connected your GSM device to. Often, this device has a group ownership set to the dialout group, so the easieast route is to add the navcron user to the dialout group:

sudo addgroup navcron dialout

8. Ensure that a writeable uploads directory exists

The NAV web ui allows you to upload and attach images to room and location objects. These images will be stored in the file system, so NAV needs a writeable directory to store them in (and from where the web server can serve them).

We suggest:

mkdir -p /usr/share/nav/var/uploads
chown navcron:nav /usr/share/nav/var/uploads

Then, ensure you set this option in nav.conf:

UPLOAD_DIR=/usr/share/nav/var/uploads

9. Install the static resources

Run:

django-admin collectstatic --settings=nav.django.settings

It’ll respond with something like:

You have requested to collect static files at the destination
location as specified in your settings:

    /usr/share/nav/www/static

This will overwrite existing files!
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel:

Take note of the path (/usr/share/nav/www, without the static subdir), as you’ll need it in the next step and type yes and hit Enter.

This will copy static files (css, javascript, images, fonts and similar) into that path.

10. Configure Apache

Copy the file /etc/nav/apache/apache.conf.example to /etc/nav/apache/apache.conf and edit the defines inside the copy.

  • documentroot should be the path from step 9.
  • documentation_path is where Sphinx put the docs, in $SOURCE_CODE_DIRECTORY/build/sphinx/html/.
  • nav_uploads_path is the upload path you created in step 8.
  • nav_python_base should be /usr/local/lib/python2.7/dist-packages (or wherever the nav Python module was installed)

We suggest creating a new Apache site config: Inside a VirtualHost-directive, add:

/etc/apache2/sites-available/nav.conf
<VirtualHost *:80>
    ServerName nav.example.org
    ServerAdmin webmaster@example.org

    Include /etc/nav/apache/apache.conf
</VirtualHost>

You should, of course, replace nav.example.org with a DNS name that your server can actually be reached under.

Then, disable the default Apache site, enable the nav site, and enable mod_wsgi, before restarting Apache:

a2dissite 000-default
a2ensite nav
a2enmod wsgi
systemctl reload apache2

You should now be able to browse the NAV web interface.

Important

You should always protect your NAV web site using SSL!

11. Installing and configuring Graphite

NAV uses Graphite to store and retrieve time-series data. A somewhat outdated guide for installing Graphite for use with NAV on a Debian system can be found in the wiki. This guide will be updated and included in the official documentation.

Start using NAV

You should now be ready to move on the the Getting started with NAV guide.