Install NetBox on Debian
NetBox requires PostgreSQL and Redis as dependencies. This guide skips their installation — please complete those first.
Install pre-required packages:
1
sudo apt install -y curl python3 python3-pip python3-venv python3-dev build-essential libxml2-dev libxslt1-dev libffi-dev libpq-dev libssl-dev zlib1g-dev
Check the Python version:
1
python3 -V
Download NetBox
Download the latest stable release from GitHub and extract to /opt/netbox. This example uses version 4.1.7:
1
2
3
sudo wget https://github.com/netbox-community/netbox/archive/refs/tags/v4.1.7.tar.gz
sudo tar -xzf v4.1.7.tar.gz -C /opt
sudo ln -s /opt/netbox-4.1.7/ /opt/netbox
Create the NetBox System User
Create a system user named netbox and assign ownership of the media directories:
1
2
3
4
sudo adduser --system --group netbox
sudo chown --recursive netbox /opt/netbox/netbox/media/
sudo chown --recursive netbox /opt/netbox/netbox/reports/
sudo chown --recursive netbox /opt/netbox/netbox/scripts/
Configuration
Copy the example configuration and update ALLOWED_HOST, DATABASE, REDIS, and SECRET_KEY:
1
2
cd /opt/netbox/netbox/netbox/
sudo cp configuration_example.py configuration.py
Generate a secret key using the pre-defined script:
1
python3 ../generate_secret_key.py
Run the Upgrade Script
Run the packaged upgrade script to:
- Create a Python virtual environment
- Install all required Python packages
- Run database schema migrations
- Build documentation locally
- Aggregate static resource files
1
sudo /opt/netbox/upgrade.sh
Create a Superuser
Activate the virtual environment:
1
source /opt/netbox/venv/bin/activate
Create the superuser:
1
2
cd /opt/netbox/netbox
python3 manage.py createsuperuser
Schedule the Housekeeping Task
1
sudo ln -s /opt/netbox/contrib/netbox-housekeeping.sh /etc/cron.daily/netbox-housekeeping
Gunicorn
NetBox ships with a default gunicorn configuration:
1
sudo cp /opt/netbox/contrib/gunicorn.py /opt/netbox/gunicorn.py
Setup systemd
Copy the service files and reload systemd:
1
2
sudo cp -v /opt/netbox/contrib/*.service /etc/systemd/system/
sudo systemctl daemon-reload
Enable and start the services:
1
sudo systemctl enable --now netbox netbox-rq
Verify the service is running:
1
systemctl status netbox.service
Setup NGINX
Install NGINX:
1
sudo apt install -y nginx
Copy the NetBox-provided NGINX configuration (update server_name with your domain or IP):
1
sudo cp /opt/netbox/contrib/nginx.conf /etc/nginx/sites-available/netbox
Remove the default site and enable NetBox:
1
2
sudo rm /etc/nginx/sites-enabled/default
sudo ln -s /etc/nginx/sites-available/netbox /etc/nginx/sites-enabled/netbox
(Optional) Install NGINX-UI
To manage NGINX and automate SSL certificates with a UI:
1
bash <(curl -L -s https://raw.githubusercontent.com/0xJacky/nginx-ui/master/install.sh) install
Access NGINX-UI at http://ip.address:9000. Once configured, access NetBox at https://ip.address.