Centos 7 安装Netbox
##### install postgresql ##############
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo yum -y repolist
sudo yum -y update
sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum -y install postgresql15-server
psql -V
sudo /usr/pgsql-15/bin/postgresql-15-setup initdb
sudo systemctl enable --now postgresql-15
systemctl status postgresql*
sudo passwd postgres
su - postgres
psql -c "ALTER USER postgres WITH PASSWORD 'StrongPassw0rd';"
psql
CREATE DATABASE netbox;
CREATE USER netbox WITH PASSWORD 'SjUrMk8Zq193k';
GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;
ALTER DATABASE netbox OWNER TO netbox;
psql --username netbox --password --host localhost netbox
##### install redis ##################
sudo yum install -y redis
sudo systemctl start redis
sudo systemctl enable redis
redis-server -v
redis-cli ping
##### install python3.11.2 ####################
tar -zxf Python-3.11.2.tgz
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc libffi-devel
cd Python-3.11.2
./configure --prefix=/opt/Python3/
make && make install
cd /usr/bin/
unlink python
ln -s /opt/Python3/bin/python3 /usr/bin/python
ln -s /opt/Python3/bin/python3 /usr/bin/python3
vi /usr/bin/yum
vi /usr/libexec/urlgrabber-ext-down
ln -s /opt/Python3/bin/pip3 /usr/bin/pip
ln -s /opt/Python3/bin/pip3 /usr/bin/pip3
##### install openssl ##################
wget https://github.com/openssl/openssl/archive/OpenSSL_1_1_1t.tar.gz
tar -zxvf openssl_1_1_1t.tar.gz
cd openssl-OpenSSL_1_1_1d
./config --prefix=/opt/openssl // 指定安装路径
make && make install
mv /usr/bin/openssl /usr/bin/openssl.old
mv /usr/lib64/openssl /usr/lib64/openssl.old
mv /usr/lib64/libssl.so /usr/lib64/libssl.so.old
ln -s /opt/openssl/bin/openssl /usr/bin/openssl
ln -s /opt/openssl/include/openssl /usr/include/openssl
ln -s /opt/openssl/lib/libssl.so /usr/lib64/libssl.so
echo "/opt/openssl/lib" >> /etc/ld.so.conf
ldconfig -v // 建立动态链接
openssl version
##### instal netbox ###########
sudo wget https://github.com/netbox-community/netbox/archive/refs/tags/v3.4.4.tar.gz
sudo tar -xzf v3.4.4.tar.gz -C /opt
sudo ln -s /opt/netbox-3.4.4/ /opt/netbox
[root@s01 netbox]# python3 ../generate_secret_key.py
+C80MG3#Po+&-CY11DW%JS0D2*QnqtSA#$!@rskm&qx1waCI)N9D
##########其他参照https://docs.netbox.dev/en/stable/installation/#########
##### install nginx #######
[root@s01 ~]# cat /etc/nginx/nginx.conf
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 4096;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
#########netbox config by fayong
server {
listen 80;
listen [::]:80;
server_name _;
root /usr/share/nginx/html;
return 301 https://$host$request_uri;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
server {
listen [::]:443 ssl ipv6only=off;
# CHANGE THIS TO YOUR SERVER'S NAME
server_name 172.16.151.16;
ssl_certificate /etc/ssl/certs/netbox.crt;
ssl_certificate_key /etc/ssl/private/netbox.key;
client_max_body_size 25m;
location /static/ {
alias /opt/netbox/netbox/static/;
}
location / {
proxy_pass http://127.0.0.1:8001;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
# Settings for a TLS enabled server.
#
# server {
# listen 443 ssl http2;
# listen [::]:443 ssl http2;
# server_name _;
# root /usr/share/nginx/html;
#
# ssl_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }
}