

How to Install NetBox on CentOS 7 with Apache and Supervisord
source link: https://computingforgeeks.com/how-to-install-netbox-on-centos-7-with-apache-and-supervisord/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Welcome to our guide on how to Install Netbox on CentOS 7 with Apache and Supervisord. NetBox is an open source web application designed to help manage and document computer networks. Initially conceived by the network engineering team at DigitalOcean.
Netbox encompasses the following aspects of network management:
- IP address management (IPAM) – IP networks and addresses, VRFs, and VLANs
- Equipment racks – Organized by group and site
- Devices – Types of devices and where they are installed
- Connections – Network, console, and power connections among devices
- Virtualization – Virtual machines and clusters
- Data circuits – Long-haul communications circuits and providers
- Secrets – Encrypted storage of sensitive credentials
For Ubuntu / Debian, check:
How To Install NetBox IPAM on Debian 10 Linux
How to Install NetBox on Ubuntu 18.04 LTS
For Ubuntu 16.04, use How to install NetBox on Ubuntu 16.04
How to install Netbox on CentOS 7
Follow steps below to install Netbox on your CentOS 7 server.
Add EPEL repository
We need an epel repository to install some dependency packages. Add it to your CentOS 7 server using the following commands:
sudo yum -y install epel-release
Disable SELinux
As we will be using custom TCP ports, it is recommended to disable or put SELinux in permissive mode unless you know how to work with the tool.
sudo setenforce 0 sudo sed -i --follow-symlinks 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
Install dependency packages
sudo yum install -y gcc httpd git libxml2-devel libxslt libffi-devel graphviz libxslt-devel supervisor
Install Python 3.6
sudo yum -y install yum-utils
sudo yum -y install https://centos7.iuscommunity.org/ius-release.rpm
sudo yum -y install python36u python36u-devel
sudo yum -y install python36u-pip
Install and configure PostgreSQL database server
Install PostgreSQL 9.6
sudo rpm -ivh https://yum.postgresql.org/9.6/redhat/rhel-7.3-x86_64/pgdg-centos96-9.6-3.noarch.rpm
sudo yum install postgresql96 postgresql96-server postgresql96-libs postgresql96-contrib postgresql96-devel
Initialize database
# /usr/pgsql-9.6/bin/postgresql96-setup initdb
Initializing database ... OK
Start and enable PostgreSQL service to start on boot
sudo systemctl enable postgresql-9.6
sudo systemctl start postgresql-9.6
sudo systemctl status postgresql-9.6
Create a database and user for NetBox
$ sudo -u postgres psql
CREATE DATABASE netbox;
CREATE USER netbox WITH PASSWORD 'StrongPassword';
GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;
\q
Enable password login to PostgreSQL database
sudo sed -i -e 's/ident/md5/' /var/lib/pgsql/9.6/data/pg_hba.conf
Restart database service for the changes to take effect
sudo systemctl restart postgresql-9.6
Confirm that you can login to database as netbox
user
$ psql -U netbox -h localhost -W
Password for user netbox:
psql (9.2.23)
Type "help" for help.
netbox=>
Install and configure Netbox
Change to /opt/
directory
cd /opt/
git clone -b master https://github.com/digitalocean/netbox.git
Create a configuration file
cd netbox/netbox/netbox/
sudo cp configuration.example.py configuration.py
Edit the configuration file and set allowed host and database login details
# Example: ALLOWED_HOSTS = ['netbox.example.com', 'netbox.internal.local']
ALLOWED_HOSTS = ['10.1.1.20']
# PostgreSQL database configuration.
DATABASE = {
'NAME': 'netbox', # Database name
'USER': 'netbox', # PostgreSQL username
'PASSWORD': 'StrongPassword', # PostgreSQL password
'HOST': 'localhost', # Database server
'PORT': '', # Database port (leave blank for default)
}
Generate Django SECRET Key:
cd /opt/netbox/netbox
sudo ./generate_secret_key.py
Then set the key on configuration.py
file
SECRET_KEY = '30m&hqd@09h2i5hro=^l8wqtjw2$!3j%=f2!zh_sey+13jg%3$'
Install Nextbox dependencies
sudo pip3.6 install -r /opt/netbox/requirements.txt
Migrate database data
cd /opt/netbox/netbox/
sudo python3.6 manage.py migrate
Create admin user
$ sudo python3.6 manage.py createsuperuser
Username (leave blank to use 'root'): admin
Email address: [email protected]
Password:
Password (again):
Superuser created successfully.
Move static files
cd /opt/netbox/netbox
sudo python3.6 manage.py collectstatic
Load initial data
$ sudo python3.6 manage.py loaddata initial_data
Installed 53 object(s) from 5 fixture(s)python3.6 manage.py loaddata initial_data
Install gunicorn using pip3.6
$ sudo pip3.6 install gunicorn
Collecting gunicorn
Downloading https://files.pythonhosted.org/packages/8c/da/b8dd8deb741bff556db53902d4706774c8e1e67265f69528c14c003644e6/gunicorn-19.9.0-py2.py3-none-any.whl (112kB) 100% |████████████████████████████████| 122kB 737kB/s
Installing collected packages: gunicorn
Successfully installed gunicorn-19.9.0
Configure gunicorn for Netbox
sudo vim /opt/netbox/gunicorn_config.py
command = '/usr/bin/gunicorn'
pythonpath = '/opt/netbox/netbox'
bind = '127.0.0.1:8001'
workers = 3
user = 'apache'
Create a supervisor configuration
$ sudo vim /etc/supervisord.d/netbox.ini
[program:netbox]
command = gunicorn -c /opt/netbox/gunicorn_config.py netbox.wsgi
directory = /opt/netbox/netbox/
user = apache
Start and enable supervisord
sudo systemctl enable supervisord
sudo systemctl start supervisord
Configure httpd or Nginx
For Apache, create VirtualHost on /etc/httpd/conf.d/netbox.conf
Listen 8085
ProxyPreserveHost On
ServerName netbox.example.com
Alias /static /opt/netbox/netbox/static
<Directory /opt/netbox/netbox/static>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Require all granted
</Directory>
<Location /static>
ProxyPass !
</Location>
ProxyPass / http://127.0.0.1:8001/
ProxyPassReverse / http://127.0.0.1:8001/
Check apache configuration syntax and restart httpd
service
$ sudo httpd -t
Syntax OK
$ sudo systemctl restart httpd
Confirm that the service is listening
# ss -tunelp | grep 8085
tcp LISTEN 0 128 :::8085 :::* users:(("httpd",pid=2471,fd=6),("httpd",pid=2470,fd=6),("httpd",pid=2468,fd=6),("httpd",pid=2466,fd=6),("httpd",pid=2465,fd=6),("httpd",pid=2464,fd=6),("httpd",pid=2463,fd=6)) ino:54671265 sk:ffff9890baf47700 v6only:0 <->
For Nginx
Install nginx package
sudo yum -y install nginx
Create a VirtualHost file –> /etc/nginx/conf.d/netbox.conf
server {
listen 80;
server_name netbox.example.com;
client_max_body_size 25m;
location /static/ {
alias /opt/netbox/netbox/static/;
}
location / {
proxy_pass http://127.0.0.1:8001;
}
}
Check syntax and start nginx
sudo nginx -t
sudo systemctl start nginx
sudo systemctl enable nginx
Configure firewalld
If you have a running firewalld service, enable netbox port
sudo firewall-cmd --permanent --add-port=8085/tcp
sudo firewall-cmd --reload
Access Netbox Web UI
Open your default web browser and open Netbox server IP and port configured on Apache.
Recommend
-
48
README.md
-
49
README.md 前言 适合基于ssh秘钥的中小公司环境, 代码逻辑简单, 需要运维兄弟会一点python, 自定义与公司业务相关的功能,自行发挥.
-
7
How To Install NetBox on Ubuntu 18.04 LTSSearch ComputingForGeeksHow to Install NetBox on Ubuntu 18.04 LTS i...
-
9
IntroductionNetBox is an open source web application designed to help manage and document computer networks. Initially conceived by the network engineering team at DigitalOcean,“But godliness with contentment is great gain”
-
56
Install NetBox IPAM on Rocky Linux 8|CentOS 8Search ComputingForGeeksNetbox is a free and open-source tool u...
-
23
Install NetBox IPAM & DCIM Tool on Ubuntu 20.04Search ComputingForGeeksA well-documented infrastructure...
-
5
如何使用 Nginx + supervisord 部署 Hyperf 项目 Published on Dec 3, 2021 in PHP with 0 comment ...
-
4
How To Install NetBox IPAM Tool on CentOS 7Search ComputingForGeeksWelcome to our guide on how to Install Ne...
-
7
四位一体水溶交融,Docker一拖三Tornado6.2 + Nginx + Supervisord非阻塞负载均衡容器式部署实践 首页 - Python /2022-01-07...
-
12
<?xml encoding="utf-8" ??>Introduction NetBox is an open-source, web-based Infrastructure Resource Modeling (IRM) application used for automating most networking operations. IP Address Managemen...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK