Advertisement
nguyenhappy92

How to Install NetBox on CentOS 7

Aug 12th, 2019
700
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. yum install epel-release -y
  2. yum update -y
  3. setenforce 0
  4. sed -i --follow-symlinks 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
  5. yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm -y
  6. yum install postgresql96 postgresql96-server postgresql96-devel -y
  7. /usr/pgsql-9.6/bin/postgresql96-setup initdb
  8. sed -i -e 's/ident/md5/' /var/lib/pgsql/9.6/data/pg_hba.conf
  9. systemctl start postgresql-9.6
  10. systemctl enable postgresql-9.6
  11. sudo -u postgres psql
  12. CREATE DATABASE netbox;
  13. CREATE USER netbox WITH PASSWORD 'J5brHrAXFLQSif0K';
  14. GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;
  15. \q
  16. psql -U netbox -h localhost -W
  17. yum -y install yum-utils
  18. yum -y install https://centos7.iuscommunity.org/ius-release.rpm
  19. yum install -y gcc wget httpd httpd-devel python36 python36-devel python36-setuptools libxml2-devel libxslt-devel libffi-devel graphviz openssl-devel redhat-rpm-config redis
  20. easy_install-3.6 pip
  21. ln -s /usr/bin/python3.6 /usr/bin/python3
  22. systemctl enable redis
  23. systemctl start redis
  24. systemctl start httpd
  25. systemctl enable httpd
  26. wget https://github.com/netbox-community/netbox/archive/v2.6.2.tar.gz
  27. tar -xzf v2.6.2.tar.gz -C /opt/
  28. cd /opt/
  29. ln -s netbox-2.6.2/ netbox
  30. cd /opt/netbox/
  31. pip3 install -r requirements.txt
  32. pip3 install napalm
  33. cd netbox
  34. ./generate_secret_key.py
  35. cd netbox
  36. cp configuration.example.py configuration.py
  37. configuration.py
  38. ALLOWED_HOSTS = ['netbox.demo.com', '192.16.111.132','127.0.0.1']
  39. cd /opt/netbox/netbox/
  40. python3 manage.py migrate
  41. python3 manage.py createsuperuser
  42. python3 manage.py collectstatic --no-input
  43. python3 manage.py loaddata initial_data
  44. python3 manage.py runserver 0.0.0.0:8000 --insecure
  45. vi /etc/httpd/conf.d/netbox.conf
  46. <VirtualHost *:80>
  47. ProxyPreserveHost On
  48.  
  49. ServerName netbox.demo.com
  50.  
  51. Alias /static /opt/netbox/netbox/static
  52.  
  53. # Needed to allow token-based API authentication
  54.  
  55.  
  56. <Directory /opt/netbox/netbox/static>
  57. Options Indexes FollowSymLinks MultiViews
  58. AllowOverride None
  59. Require all granted
  60. </Directory>
  61.  
  62. <Location /static>
  63. ProxyPass !
  64. </Location>
  65. ProxyPass / http://127.0.0.1:8001/
  66. ProxyPassReverse / http://127.0.0.1:8001/
  67. </VirtualHost>
  68.  
  69. pip3 install gunicorn
  70. vi /opt/netbox/gunicorn_config.py
  71. command = '/usr/bin/gunicorn'
  72. pythonpath = '/opt/netbox/netbox'
  73. bind = '127.0.0.1:8001'
  74. workers = 3
  75. user = 'apache'
  76. yum install -y supervisor
  77. vi /etc/supervisord.d/netbox.ini
  78.  
  79. [program:netbox]
  80. command = gunicorn -c /opt/netbox/gunicorn_config.py netbox.wsgi
  81. directory = /opt/netbox/netbox/
  82. user = apache
  83. [program:netbox-rqworker]
  84. command = python3 /opt/netbox/netbox/manage.py rqworker
  85. directory = /opt/netbox/netbox/
  86. user = apache
  87. systemctl start supervisord
  88. systemctl enable supervisord
  89. firewall-cmd --add-port=8085/tcp --permanent
  90. firewall-cmd --add-port=80/tcp --permanent
  91. firewall-cmd --add-port=443/tcp --permanent
  92. firewall-cmd --add-port=6379/tcp --permanent
  93. firewall-cmd --add-port=5432/tcp --permanent
  94. firewall-cmd --reload
  95. systemctl restart httpd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement