可以参考官方的文档:http://docs.jumpserver.org/zh/docs/introduce.html
测试环境
- 系统: CentOS 7
- IP: 192.168.244.144
- 设置 selinux 和防火墙
$ firewall-cmd --zone=public --add-port=80/tcp --permanent # nginx 端口 $ firewall-cmd --zone=public --add-port=2222/tcp --permanent # 用户SSH登录端口 coco $ firewall-cmd --reload # 重新载入规则 $ setenforce 0 $ sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config # 修改字符集, 否则可能报 input/output error的问题, 因为日志里打印了中文 $ localedef -c -f UTF-8 -i zh_CN zh_CN.UTF-8 $ export LC_ALL=zh_CN.UTF-8 $ echo 'LANG="zh_CN.UTF-8"' > /etc/locale.conf
一. 准备 Python3 和 Python 虚拟环境
1.1 安装依赖包
$ yum -y install wget gcc epel-release git
1.2 安装 Python3.6
$ yum -y install python36 python36-devel # 如果下载速度很慢, 可以换国内源 $ wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo $ yum -y install python36 python36-devel
1.3 建立 Python 虚拟环境
因为 CentOS 7 自带的是 Python2, 而 Yum 等工具依赖原来的 Python, 为了不扰乱原来的环境我们来使用 Python 虚拟环境
$ cd /opt $ python3.6 -m venv py3 $ source /opt/py3/bin/activate # 看到下面的提示符代表成功, 以后运行 Jumpserver 都要先运行以上 source 命令, 以下所有命令均在该虚拟环境中运行 (py3) [root@localhost py3]
二. 安装 Jumpserver
2.1 下载或 Clone 项目
项目提交较多 git clone 时较大, 你可以选择去 Github 项目页面直接下载zip包。
$ cd /opt/ $ git clone --depth=1 https://github.com/jumpserver/jumpserver.git
2.2 安装依赖 RPM 包
$ cd /opt/jumpserver/requirements $ yum -y install $(cat rpm_requirements.txt) # 如果没有任何报错请继续
2.3 安装 Python 库依赖
$ pip install --upgrade pip setuptools $ pip install -r requirements.txt # 如果下载速度很慢, 可以换国内源 $ pip install --upgrade pip setuptools -i https://mirrors.aliyun.com/pypi/simple/ $ pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
2.4 安装 Redis, Jumpserver 使用 Redis 做 cache 和 celery broke
$ yum -y install redis $ systemctl enable redis $ systemctl start redis
2.5 安装 MySQL
本教程使用 Mysql 作为数据库, 如果不使用 Mysql 可以跳过相关 Mysql 安装和配置
$ yum -y install mariadb mariadb-devel mariadb-server # centos7下安装的是mariadb $ systemctl enable mariadb $ systemctl start mariadb
2.6 创建数据库 Jumpserver 并授权
$ DB_PASSWORD=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 24` # 生成随机数据库密码 $ echo -e "