インストールガイド · 3 min read · Nov 19, 2025
Ubuntu 20.04 LTSにNetBoxネットワークドキュメンテーションおよび管理ツールをインストールする方法

Netboxは、無料で強力なIPアドレス(IPAM)およびデータセンターインフラ管理(DCIM)ツールです。ネットワーク、VM、インベントリなどの情報を保存するために使用されます。元々はDigitalOceanのネットワークエンジニアリングチームによって開発されました。このツールはDjango Pythonフレームワークで書かれており、PostgreSQLデータベースに依存しています。その目的は、ネットワーク操作のためのドメイン特化型の真実のソースとして機能することです。
このチュートリアルでは、Ubuntu 20.04でNginxをリバースプロキシとして使用してNetboxをインストールする方法を説明します。
前提条件
- Ubuntu 20.04を実行しているサーバー。
- サーバーに設定されたrootパスワード。
始めに
始める前に、Netboxに必要な依存関係をいくつかインストールする必要があります。次のコマンドを実行することで、すべてをインストールできます:
apt-get install nginx git gcc supervisor python3 python3-dev python3-pip python3-setuptools build-essential libxml2-dev libxslt1-dev libffi-dev graphviz libpq-dev libssl-dev zlib1g-dev -yすべてのパッケージがインストールされたら、次のステップに進むことができます。
PostgreSQLデータベースのインストールと設定
NetboxはデータストレージのためにPostgreSQLデータベースに依存しています。次のコマンドでインストールできます:
apt-get install postgresql postgresql-contrib -yPostgreSQLがインストールされたら、次のコマンドでPostgreSQLにログインします:
su - postgres
postgres@ubuntu2004:~$ psql次の出力が得られるはずです:
psql (12.2 (Ubuntu 12.2-4))
Type "help" for help.
次に、次のコマンドでNetbox用のデータベースとユーザーを作成します:
postgres=# CREATE DATABASE netbox;
postgres=# CREATE USER netbox WITH PASSWORD 'password';次に、次のコマンドでNetboxデータベースにすべての権限を付与します:
postgres=# GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;次に、次のコマンドでPostgreSQLシェルから退出します:
postgres=# exit
postgres@ubuntu2004:~$ exitNetBoxのインストールと設定
まず、/optディレクトリに移動し、次のコマンドを使用してGit HubリポジトリからNetboxの最新バージョンをダウンロードします:
cd /opt/
git clone -b master https://github.com/digitalocean/netbox.git次に、次のコマンドでPythonバイナリのシンボリックリンクを作成します:
ln -s /usr/bin/python3 /usr/bin/python次に、/opt/netbox/netbox/に移動し、次のコマンドを実行してDjango SECRET Keyを生成します:
cd /opt/netbox/netbox/
./generate_secret_key.py次の出力が得られるはずです:
wcq@L2)eTDpo(k^f4Sm9bariUnK0syCPMGEIjW6XV_8l5xhB7z
次に、netboxディレクトリに移動し、例の設定ファイルの名前を変更します:
cd netbox
mv configuration.example.py configuration.py次に、Netbox設定ファイルを編集し、データベース、シークレットキー、および許可されたホストを定義します:
nano configuration.py次の変更を行います:
ALLOWED_HOSTS = ['your-server-ip']
# PostgreSQLデータベースの設定。利用可能なパラメータの完全なリストについては、Djangoのドキュメントを参照してください:
# https://docs.djangoproject.com/en/stable/ref/settings/#databases
DATABASE = {
'NAME': 'netbox', # データベース名
'USER': 'netbox', # PostgreSQLユーザー名
'PASSWORD': 'password', # PostgreSQLパスワード
'HOST': 'localhost', # データベースサーバー
'PORT': '', # データベースポート(デフォルトの場合は空白のままにします)
'CONN_MAX_AGE': 300, # 最大データベース接続年齢
}
SECRET_KEY = 'wcq@L2)eTDpo(k^f4Sm9bariUnK0syCPMGEIjW6XV_8l5xhB7z'
ファイルを保存して閉じたら、次のコマンドでPythonの依存関係をすべてインストールします:
pip3 install -r /opt/netbox/requirements.txt次に、次のコマンドでデータベースをマイグレーションします:
cd /opt/netbox/netbox/
python3 manage.py migrate次に、次のコマンドでNetbox管理ユーザーを作成します:
python3 manage.py createsuperuser次のように、ユーザー名とパスワードを提供するように求められます:
Username (leave blank to use 'root'): netboxadmin
Email address: [email protected]
Password:
Password (again):
Superuser created successfully.
次に、次のコマンドで静的ファイルを収集します:
python3 manage.py collectstatic次の出力が得られるはずです:
976 static files copied to '/opt/netbox/netbox/static'.
Gunicornのインストールと設定
NetboxはDjangoベースのアプリケーションです。したがって、システムにGunicornをインストールする必要があります。次のコマンドを実行してインストールできます:
pip3 install gunicornGunicornをインストールした後、次のコマンドでNetbox用の新しいGunicorn設定ファイルを作成します:
nano /opt/netbox/gunicorn_config.py次の行を追加します:
command = '/usr/local/bin/gunicorn'
pythonpath = '/opt/netbox/netbox'
bind = 'your-server-ip:8001'
workers = 3
user = 'www-data'
完了したら、ファイルを保存して閉じます。
Supervisorのインストールと設定
Supervisorは、NetBoxサービスを監視および制御するためのクライアント/サーバーシステムです。次のコマンドでNetbox用の新しいSupervisor設定ファイルを作成できます:
nano /etc/supervisor/conf.d/netbox.conf次の行を追加します:
[program:netbox]
command = gunicorn -c /opt/netbox/gunicorn_config.py netbox.wsgi
directory = /opt/netbox/netbox/
user = www-data
完了したら、ファイルを保存して閉じます。次に、次のコマンドでSupervisorサービスを再起動します:
systemctl restart supervisor次のコマンドを使用してSupervisorサービスのステータスを確認することもできます:
systemctl status supervisor次の出力が得られるはずです:
? supervisor.service - Supervisor process control system for UNIX
Loaded: loaded (/lib/systemd/system/supervisor.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2020-05-30 05:49:08 UTC; 14s ago
Docs: http://supervisord.org
Main PID: 550606 (supervisord)
Tasks: 5 (limit: 4691)
Memory: 184.3M
CGroup: /system.slice/supervisor.service
??550606 /usr/bin/python3 /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
??550626 /usr/bin/python3 /usr/local/bin/gunicorn -c /opt/netbox/gunicorn_config.py netbox.wsgi
??550628 /usr/bin/python3 /usr/local/bin/gunicorn -c /opt/netbox/gunicorn_config.py netbox.wsgi
??550629 /usr/bin/python3 /usr/local/bin/gunicorn -c /opt/netbox/gunicorn_config.py netbox.wsgi
??550630 /usr/bin/python3 /usr/local/bin/gunicorn -c /opt/netbox/gunicorn_config.py netbox.wsgi
May 30 05:49:08 ubuntu2004 systemd[1]: Started Supervisor process control system for UNIX.
May 30 05:49:08 ubuntu2004 supervisord[550606]: 2020-05-30 05:49:08,664 CRIT Supervisor is running as root. Privileges were not dropped becau>
May 30 05:49:08 ubuntu2004 supervisord[550606]: 2020-05-30 05:49:08,664 INFO Included extra file "/etc/supervisor/conf.d/netbox.conf" during p>
May 30 05:49:08 ubuntu2004 supervisord[550606]: 2020-05-30 05:49:08,671 INFO RPC interface 'supervisor' initialized
May 30 05:49:08 ubuntu2004 supervisord[550606]: 2020-05-30 05:49:08,671 CRIT Server 'unix_http_server' running without any HTTP authentication>
May 30 05:49:08 ubuntu2004 supervisord[550606]: 2020-05-30 05:49:08,672 INFO supervisord started with pid 550606
May 30 05:49:09 ubuntu2004 supervisord[550606]: 2020-05-30 05:49:09,676 INFO spawned: 'netbox' with pid 550626
May 30 05:49:11 ubuntu2004 supervisord[550606]: 2020-05-30 05:49:11,060 INFO success: netbox entered RUNNING state, process has stayed up for
NginxのNetBox用設定
Netboxにポート80でアクセスするためにNginxをリバースプロキシとして設定するのは良いアイデアです。次のコマンドを使用して新しいNginx仮想ホスト設定を作成できます:
nano /etc/nginx/sites-available/netbox.conf次の行を追加します:
server {
listen 80;
server_name your-server-ip;
client_max_body_size 25m;
location /static/ {
alias /opt/netbox/netbox/static/;
}
location / {
proxy_pass http://your-server-ip:8001;
}
}
ファイルを保存して閉じたら、/etc/nginx/sites-enabled/ディレクトリへのシンボリックリンクを作成します:
ln -s /etc/nginx/sites-available/netbox.conf /etc/nginx/sites-enabled/次に、次のコマンドでNginxの構文エラーを確認します:
ginx -tすべてが正常であれば、次の出力が得られるはずです:
ginx: the configuration file /etc/nginx/nginx.conf syntax is ok
ginx: configuration file /etc/nginx/nginx.conf test is successful
最後に、変更を実装するためにNginxサービスを再起動します。
systemctl restart nginx次のコマンドを使用してNginxを確認することもできます:
systemctl status nginx次の出力が得られるはずです:
? nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: active (running) since Sat 2020-05-30 22:28:13 EST; 4min 14s ago
Process: 984 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 982 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 980 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 985 (nginx)
Tasks: 3 (limit: 25028)
Memory: 5.5M
CGroup: /system.slice/nginx.service
??985 nginx: master process /usr/sbin/nginx
??986 nginx: worker process
??987 nginx: worker process
May 30 21:28:12 ubuntu2004 systemd[1]: Starting The nginx HTTP and reverse proxy server...
Mar 30 21:28:12 ubuntu2004 nginx[982]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Mar 30 21:28:12 ubuntu2004 nginx[982]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Mar 30 21:28:13 ubuntu2004 systemd[1]: Started The nginx HTTP and reverse proxy server.
この時点で、Nginxウェブサーバーはポート80でNetboxを提供するように設定されています。これで、Netboxウェブインターフェースにアクセスできます。
Netboxウェブインターフェースにアクセスする
ウェブブラウザを開き、URL http://your-server-ip にアクセスします。次のページにリダイレクトされます:

ログインボタンをクリックします。次の画面にNetboxログインページが表示されるはずです:

Netbox管理者のユーザー名、パスワードを入力し、ログインボタンをクリックします。次のページにNetboxのデフォルトダッシュボードが表示されるはずです:

結論
このガイドでは、Ubuntu 20.04にNginxを使用してNetboxをインストールする方法を学びました。これで、ネットワークインフラを文書化し始めることができます。詳細については、Netboxの公式ドキュメントを訪問してください。質問があればお気軽にお尋ねください。
新しい投稿を受信箱で受け取る
スパムはありません。いつでも購読を解除できます。