阿里云ECS安装 jumpserver1.5.2

阿里云ECS

公网IP :47.98.237.233

内网IP:172.16.100.255

在“安全组” 开通ECS的相关端口

阿里云ECS安装 jumpserver1.5.2

一. 准备 Python3 和 Python 虚拟环境

yum -y install wget sqlite-devel xz gcc automake zlib-devel openssl-devel epel-release git
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
tar xvf Python-3.6.1.tar.xz  && cd Python-3.6.1
./configure && make && make install
cd /opt
python3 -m venv py3
source /opt/py3/bin/activate

# 看到下面的提示符代表成功,以后运行 Jumpserver 都要先运行以上 source 命令,以下所有命令均在该虚拟环境中运行
(py3) [root@localhost py3]

二. 安装 Jumpserver 1.5.2

2.1 下载或 Clone 项目

项目提交较多 git clone 时较大,你可以选择去 Github 项目页面直接下载zip包,我是下载安装包之后安装

阿里云ECS安装 jumpserver1.5.2
cd /opt/
#git clone --depth=1 https://github.com/jumpserver/jumpserver.git && cd jumpserver && git checkout master   (从官网下载直接安装)
下载安装包之后把下载的jumpserver-master.zip上传到 /opt目录
unzip jumpserver-master.zip
mv jumpserver-master jumpserver
阿里云ECS安装 jumpserver1.5.2
2.2 安装依赖 RPM 包
cd /opt/jumpserver/requirements yum -y install $(cat rpm_requirements.txt) # 如果没有任何报错请继续,报错多测试几次

2.3 安装 Python 库依赖

pip install -r requirements.txt  # 不要指定-i参数,因为镜像上可能没有最新的包,如果没有任何报错请继续,报错多测试几次

2.4 安装 Redis, Jumpserver 使用 Redis 做 cache 和 celery broke

yum -y install redis
systemctl start redis
systemctl enable redis

2.5 安装 MySQL

yum -y install mariadb mariadb-devel mariadb-server # centos7下安装的是mariadb
systemctl start mariadb
systemctl enable mariadb

2.6 创建数据库 Jumpserver 并授权

$ mysql
> create database jumpserver default charset 'utf8';
> grant all on jumpserver.* to 'jumpserver'@'127.0.0.1' identified by 'jason_zhang';

> FLUSH PRIVILEGES;

2.7 修改 Jumpserver 配置文件

$ cd /opt/jumpserver
$ cp config_example.yml config.yml

$ SECRET_KEY=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 50`  # 生成随机SECRET_KEY
$ echo "SECRET_KEY=$SECRET_KEY" >> ~/.bashrc
$ BOOTSTRAP_TOKEN=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 16`  # 生成随机BOOTSTRAP_TOKEN
$ echo "BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN" >> ~/.bashrc

$ sed -i "s/SECRET_KEY:/SECRET_KEY: $SECRET_KEY/g" /opt/jumpserver/config.yml
$ sed -i "s/BOOTSTRAP_TOKEN:/BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN/g" /opt/jumpserver/config.yml
$ sed -i "s/# DEBUG: true/DEBUG: false/g" /opt/jumpserver/config.yml
$ sed -i "s/# LOG_LEVEL: DEBUG/LOG_LEVEL: ERROR/g" /opt/jumpserver/config.yml
$ sed -i "s/# SESSION_EXPIRE_AT_BROWSER_CLOSE: false/SESSION_EXPIRE_AT_BROWSER_CLOSE: true/g" /opt/jumpserver/config.yml
$ sed -i "s/DB_PASSWORD: /DB_PASSWORD: $DB_PASSWORD/g" /opt/jumpserver/config.yml

$ echo -e "