This tutorial covers the installation of Netbox onto Ubuntu Server version 19.1.
As always start with updating your apt repository. Once updated install the required preqs for installation including git which we will use to clone the latest version of netbox. Run the commands individually.
sudo apt-get update
sudo apt-get install -y postgresql libpq-dev
sudo apt-get install -y python3 python3-pip python3-dev build-essential libxml2-dev libxslt1-dev libffi-dev libpq-dev libssl-dev redis-server zlib1g-dev
Once installed you need to create a new database and user.
sudo -u postgres psql CREATE DATABASE netbox; CREATE USER netbox WITH PASSWORD 'password'; GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox; exit
Now create the following directory and navigate to /opt
sudo mkdir -p /opt/netbox/ && cd /opt/
Now clone the netbox installation files from github and install the python preqs.
sudo git clone -b master https://github.com/netbox-community/netbox.git cd netbox sudo pip3 install -r requirements.txt #optional sudo pip3 install napalm #optional sudo pip3 install django-storages cd netbox/netbox/
Now copy the example configuration file and edit with your preferred IP username and password.
sudo cp configuration.example.py configuration.py sudo vim configuration.py
The required fields are ALLOWED_HOSTS, NAME, USER, PASSWORD and SECRET_KEY in the DATABASE section of the configuration file. The allowed hosts field is not the IP addresses allowed to access the system, but the IPs or hostnames that netbox will be reachable from. For example, my VM has an IP of 192.168.93.132. So my allowed hosts configuration would look like this the below.
SECRET_KEY must be at least 50 characters long.
ALLOWED_HOSTS = ['192.168.93.132']
For those unfamiliar with editing using vim, press i to enter edit mode and press Esc to exit edit mode. Then type :wq! to save write to file(save) and quit.
Now move back into the top level netbox folder and run the database migration script.
cd .. sudo python3 manage.py migrate
Now create an admin user for Netbox.
sudo python3 manage.py createsuperuser
Now run the last two admin tasks and start the netbox server.
sudo python3 manage.py collectstatic --no-input sudo python3 manage.py runserver 0.0.0.0:80 --insecure
If you require more information on operating netbox see https://netbox.readthedocs.io/en/stable/