Netbox Production install (Non -Docker) Ubuntu 20.04 **WORKING**FREE – OPEN SOURCE -DCIM -IRM



sudo -i

sudo apt-get update
reboot

sudo apt-get install -y postgresql libpq-dev
sudo -u postgres psql

postgres=# CREATE DATABASE netbox;
postgres=# CREATE USER netbox WITH PASSWORD ‘[email protected]#$’;
postgres=# GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;
postgres=# q

psql -U netbox -W -h localhost netbox
q

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

sudo mkdir -p /opt/netbox/ && cd /opt/netbox/

sudo apt-get install -y git

sudo git clone -b master https://github.com/netbox-community/netbox.git .

pip3 install -r /opt/netbox/requirements.txt

pip3 install gunicorn

exit

cd /opt/netbox/netbox/netbox

sudo cp configuration_example.py configuration.py

sudo nano configuration.py

(update below)

ALLOWED_HOSTS = [‘*’]
USER ‘netbox’
PASSWORD ‘[email protected]#$’
SECRET_KEY – ‘ArenuLXC%0J0P%XJKTo=4(GqGJ)5P(moXpNgGAV7Y6lO=Uq%AI’

cd /opt/netbox/netbox/

python3 manage.py migrate

python3 manage.py createsuperuser

sudo python3 manage.py collectstatic –no-input

sudo apt install -y nginx

sudo nano /etc/nginx/sites-available/netbox

(copy paste below)

server {
listen 80;

server_name 10.10.10.1;

client_max_body_size 25m;

location /static/ {
alias /opt/netbox/netbox/static/;
}

location / {
proxy_pass http://127.0.0.1:8001;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
add_header P3P ‘CP=”ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV”‘;
}
}

cd /etc/nginx/sites-enabled/

sudo rm /etc/nginx/sites-enabled/default

sudo ln -s /etc/nginx/sites-available/netbox

sudo nano /opt/netbox/gunicorn_config.py
(copy paste as is below and save)

command = ‘/usr/bin/gunicorn’
pythonpath = ‘/opt/netbox/netbox’
bind = ‘127.0.0.1:8001’
workers = 3
user = ‘www-data’

sudo apt install -y supervisor

sudo nano /etc/supervisor/conf.d/netbox.conf
(copy paste below and save)

[program:netbox]
command = gunicorn -c /opt/netbox/gunicorn_config.py netbox.wsgi
directory = /opt/netbox/netbox/
user = www-data

service nginx restart

service supervisor restart

browse the ip

For permission issues while uploading images, run below command:
chmod -R 777 /opt/netbox/netbox/media/image-attachments

Leave a Reply

Your email address will not be published.