关闭防火墙关闭selinux 和 firewalld
/data/web/opsql/config/config.py
只需要修改此文件即可,不需要再修改settings.py文件
yum -y install epel-release yum -y install net-tools vim lsof lrzsz bzip2-devel wget gcc gcc-c++ make automake unzip curl curl-devel perl perl-devel expat expat-devel zlib zlib-devel asciidoc xmlto gettext-devel openssl-devel openssl mlocate python-devel openldap-devel readline-devel git mysql-devel
PS:第一句语句单独执行,后面的语句一起执行
安装python3.6
# 不指定安装位置,默认安装到/usr/local/bin目录下
wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz
tar -zxf Python-3.6.8.tgz
./configure --enable-optimizations
make && make install
PS:configure在python解压的文件夹下
激活python虚拟环境
/usr/local/bin/pip3.6 install --upgrade pip
/usr/local/bin/pip3.6 install virtualenv -i https://mirrors.aliyun.com/pypi/simple
/usr/local/bin/virtualenv /venv_py36 --python=/usr/local/bin/python3.6
echo "source /venv_py36/bin/activate" >> /root/.bashrc
source /root/.bashrc
从github下载项目代码
mkdir /data/web -p
cd /data/web
# clone到本地,命名为opsql
git clone https://github.com/lazzyfu/AuditSQL.git opsql
安装mysql
yum -y install https://repo.percona.com/yum/percona-release-latest.noarch.rpm
yum -y install Percona-Server-server-57 Percona-Server-devel-57
service mysql start
grep 'temporary password' /var/log/mysqld.log # 这一步查看初始密码
# 修改密码
alter user root@'localhost' identified by '123.com';
flush privileges;
PS:查看初始密码后需要首次登陆,修改密码策略,然后修改密码后在执行创建库
安装redis(可选)
yum -y install redis
systemctl start redis.service
安装python依赖包
cd /data/web/opsql/
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple
安装uwsgi
pip install uwsgi
安装nginx
yum -y install nginx
chown -R nginx. /data/web
chown -R nginx. /venv_py36 # 必须设置虚拟环境的用户为nginx
初始化数据
需要修改配置文件(/data/web/opsql/config/config.py)中的数据库配置
cd /data/web/opsql
# 数据库创建库和用户,该用户必须要有with grant option权限
create database opsql character set utf8;
create user 'opsql'@'%' identified by '123.com';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '1234' WITH GRANT OPTION; # 授权
flush privileges;
# 创建表结构 # 必须先安装django
python manage.py migrate
# 导入数据
mysql -uopsql -p123.com opsql < documents/initial.sql