Site icon Learning & Doing

Install netbox pada centos 7

Pada kesempatan kali ini saya akan membahas cara Install netbox pada centos 7. netbox sendiri di gunakan sebagain management IP untuk provider ISP atau data center .

- Update OS dan disable selinux

yum update -y
yum install -y epel-release
sed -i --follow-symlinks 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
shutdown -r now

- disable IPtable

systemctl stop firewalld
systemctl disable firewalld

- install requarment modul

yum install -y git gcc wget postgresql-server python-psycopg2 postgresql-devel python-devel libxml2-devel libxslt libffi-devel graphviz openssl-devel libxslt-devel httpd python-pip supervisor python-gunicorn

- setup Postgre


systemctl enable postgresql
/usr/bin/postgresql-setup initdb
systemctl start postgresql
sudo -u postgres psql

CREATE DATABASE netbox;
CREATE USER netbox WITH PASSWORD 'somepassword';
GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;
\q;

Set PSQL to allow login:

sed -i -e 's/ident/md5/' /var/lib/pgsql/data/pg_hba.conf

systemctl restart postgresql

psql -U netbox -h localhost -W
\q;

- install netbox

wget https://github.com/digitalocean/netbox/archive/v1.6.2-r1.tar.gz
tar -xzf v1.6.2-r1.tar.gz -C /opt
ln -s /opt/netbox-1.6.2-r1/ /opt/netbox
sudo pip install -r /opt/netbox/requirements.txt
cp /opt/netbox/netbox/netbox/configuration.example.py /opt/netbox/netbox/netbox/configuration.py

- ganti nama server atau IP dengan domain 

sed -i --follow-symlinks "s/ALLOWED_HOSTS = []/ALLOWED_HOSTS = ['netbox.mydomain.com']/g" /opt/netbox/netbox/netbox/configuration.py

- setting database

sed -i --follow-symlinks "s/'USER': ''/'USER': 'netbox'/g" /opt/netbox/netbox/netbox/configuration.py

- setting password DB


sed -i --follow-symlinks "s/'PASSWORD': ''/'PASSWORD': 'somepassword'/g" /opt/netbox/netbox/netbox/configuration.py

- setting secretkey -> bisa disesuaikan

sed -i --follow-symlinks "s/SECRET_KEY = ''/SECRET_KEY = 'jkC3e8tzgLrDNS0'/g" /opt/netbox/netbox/netbox/configuration.py

- migrasi data ke database

/opt/netbox/netbox/manage.py migrate

- buat user admin untuk login

/opt/netbox/netbox/manage.py createsuperuser

- Move static files (type “yes” to confirm):

/opt/netbox/netbox/manage.py collectstatic

- test running server

Run the test server:

/opt/netbox/netbox/manage.py runserver 0.0.0.0:8000 --insecure

- akses web

http://netbox.mydomain.com:8000

Integrasi ke apache web server :

- install (Apache)
yum install httpd -y

- buat 3 buah file berikut :

vi /etc/httpd/conf.d/netbox.conf

<VirtualHost *:80>
    ProxyPreserveHost On

    ServerName netbox.mydomain.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/
</VirtualHost>

vi /opt/netbox/gunicorn_config.py

command = '/usr/bin/gunicorn'
pythonpath = '/opt/netbox/netbox'
bind = '0.0.0.0:8001'
workers = 3
user = 'apache'

vi /etc/supervisord.d/netbox.ini

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

- Restart Services and Test

    systemctl enable httpd

    systemctl restart httpd

- Enable Supervisor for Startup:

    systemctl enable supervisord

- Restart Supervisor:

    systemctl restart supervisord

- Check status of Netbox Supervisor 

    supervisorctl status

- Check status of Apache (status should show green and running):

    systemctl status httpd

- akses web http://netbox.mydomain.com
Exit mobile version