$ 开头的行表示需要执行的命令
系统: CentOS 7
目录: /opt
数据库: mariadb5.5
web: nginx
$ firewall-cmd --zone=public --add-port=80/tcp --permanent
$ firewall-cmd --reload # 重新载入规则
$ setenforce 0
$ sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
$ yum -y install epel-release
$ yum -y install git nginx
$ yum -y install mariadb mariadb-devel mariadb-server MariaDB-shared
$ systemctl enable mariadb
$ systemctl start mariadb
$ DB_PASSWORD='iamadmin' # 设置数据库密码
$ mysqladmin -uroot password $DB_PASSWORD
$ mysql -uroot -p$DB_PASSWORD -e "create database cmdb default charset 'utf8';
grant all on cmdb.* to 'cmdb'@'127.0.0.1' identified by '$DB_PASSWORD'; flush privileges;"
$ yum -y install python36 python36-devel
$ cd /opt
$ python3.6 -m venv py3 # py3为虚拟环境名称, 可自定义
$ source /opt/py3/bin/activate # 退出虚拟环境可以使用 deactivate 命令
$ (py3) [root@localhost py3]
$ cd /opt/
$ git clone --depth=1 https://github.com/SuperLandy/cmdb.git
$ pip install --upgrade pip setuptools -i https://pypi.tuna.tsinghua.edu.cn/simple
$ pip install -r /opt/cmdb/requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
$ cd /opt/cmdb/cmdb/
$ cp settings_example.py settings.py
$ vi settings.py
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'cmdb',
'USER': 'cmdb',
'PASSWORD': 'iamadmin',
'HOST': '127.0.0.1',
'PORT': '3306',
}
}
$ vi /etc/nginx/conf.d/cmdb.conf
listen 80;
server_name www.example.com;
location ~/static {
root /opt/cmdb/;
}
location / {
index index.html;
proxy_pass http://127.0.0.1:8080;
}
}
$ chmod +x /opt/cmdb/start.sh
$ /opt/cmdb/start.sh
$ systemctl start nginx
$ cd /opt/cmdb/
$ source /opt/py3/bin/activate
$ python manage.py createsuperuser #根据提示输入账号密码
$ source /opt/py3/bin/activate
$ cd /opt/cmdb/ && git pull