Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
223 views4 pages

Install NetBox on Ubuntu 18.04 Guide

This document provides instructions for installing and configuring Netbox on an Ubuntu 18.04 server. It includes steps to install necessary packages like PostgreSQL, configure the database and Netbox settings, set up Supervisor and Nginx, and initialize Netbox with sample data.

Uploaded by

nenogz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
223 views4 pages

Install NetBox on Ubuntu 18.04 Guide

This document provides instructions for installing and configuring Netbox on an Ubuntu 18.04 server. It includes steps to install necessary packages like PostgreSQL, configure the database and Netbox settings, set up Supervisor and Nginx, and initialize Netbox with sample data.

Uploaded by

nenogz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

Netbox en Ubuntu 18.

04

apt-get update -y
apt-get upgrade -y
apt-get install wget ca-certificates nginx supervisor git gcc python3 python3-dev
python3-pip python3-setuptools build-essential libxml2-dev libxslt1-dev libffi-dev
graphviz libpq-dev libssl-dev zlib1g-dev unzip -y

PostgreSQL

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add


-

vi /etc/apt/sources.list.d/postgres.list
a�adir:
deb http://apt.postgresql.org/pub/repos/apt/ xanial-pgdg main

apt-get update -y
apt-get install postgresql postgresql-contrib -y

systemctl status postgresql

Creamos la BD

su - postgres
psql

CREATE DATABASE netbox;


CREATE USER netbox WITH PASSWORD 'NetBox19';
GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;
exit

Instalamos NetBox

cd /opt
git clone -b master https://github.com/digitalocean/netbox.git

cd /opt/netbox/netbox
./generate_secret_key.py

_^-w#eTZ+o8MtSkyPn(=xaORCUDdIQ@920buKGHAhNr5g%4*mE

cd netbox
mv configuration.example.py configuration.py

vi configuration.py

Modificamos con ip, datos de BD y secret key:

-En allowed hosts ponemos un nombre que hayamos puesto antes en el /etc/hosts para
que resuelva
ALLOWED_HOSTS = ['netboxnet.test.local']

# PostgreSQL database configuration.


DATABASE = {
'NAME': 'netbox', # Database name
'USER': 'netbox', # PostgreSQL username
'PASSWORD': 'NetBox19', # PostgreSQL password
'HOST': 'localhost', # Database server
'PORT': '', # Database port (leave blank for default)
}

# This key is used for secure generation of random numbers and strings. It must
never be exposed outside of this file.
# For optimal security, SECRET_KEY should be at least 50 characters in length and
contain a mix of letters, numbers, and
# symbols. NetBox will not run without this defined. For more information, see
# https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-SECRET_KEY
SECRET_KEY = '_^-w#eTZ+o8MtSkyPn(=xaORCUDdIQ@920buKGHAhNr5g%4*mE'

Instalamos dependencias:

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

Migramos la BD:

cd /opt/netbox/netbox/
python3 manage.py migrate

Creamos una cuenta de administrador para NetBox

python3 manage.py createsuperuser

root@netboxNET:/opt/netbox/netbox# python3 manage.py createsuperuser


/usr/local/lib/python3.6/dist-packages/cacheops/redis.py:21: RuntimeWarning: The
cacheops cache is unreachable! Error: Error 111 connecting to localhost:6379.
Connection refused.
warnings.warn("The cacheops cache is unreachable! Error: %s" % e, RuntimeWarning)

-->Warning por falta de Redis Server para la cach�.

Username (leave blank to use 'root'): netboxadmin


Email address: [email protected]
Password:
Password (again):
Superuser created successfully.

python3 manage.py collectstatic --no-input

Para el servicio de cach�, instalamos:

apt-get install redis-server

Cargamos datos Iniciales:

python3 manage.py collectstatic


python3 manage.py loaddata initial_data

Instalamos Gunicorn, que es necesario para netbox:

pip3 install gunicorn

Y editamos su config:
vi /opt/netbox/gunicorn_config.py

Y a�adimos:

command = '/usr/local/bin/gunicorn'
pythonpath = '/opt/netbox/netbox'
bind = 'ip_servidor:8001'
workers = 3
user = 'www-data'

Configuramos la parte de supervisor:

vi /etc/supervisor/conf.d/netbox.conf

A�adimos:

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

systemctl restart supervisor


systemctl enable supervisor
systemctl status supervisor

Configuramos la parte de Nginx:

vi /etc/nginx/sites-available/netbox

A�adimos:

server {
listen 80;
server_name nombre_con_domino;
client_max_body_size 25m;

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

location / {
proxy_pass http://ip_servidor: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"';
}
}

Habilitamos el virtual host:

ln -s /etc/nginx/sites-available/netbox.conf /etc/nginx/sites-enabled/

systemctl restart nginx

You might also like