Created 基于 CentOS 7 一步一步安装 Jumpserver 0.5.0 (markdown)

master
老广 2018-01-02 11:23:18 +08:00
parent 966cff8837
commit 8f3f7b305e
1 changed files with 238 additions and 0 deletions

@ -0,0 +1,238 @@
基于 CentOS 7 一步一步安装 Jumpserver 0.5.0
### 环境
- 系统: CentOS 7
- IP: 192.168.244.144
### 一. 准备Python3和Python虚拟环境
**1.1 安装依赖包**
```
$ yum -y install wget sqlite-devel xz gcc automake zlib-devel openssl-devel epel-release
```
**1.2 编译安装**
```
$ 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
```
**1.3 建立python虚拟环境**
因为CentOS 6/7自带的是Python2而Yum等工具依赖原来的Python为了不扰乱原来的环境我们来使用Python虚拟环境
```
$ cd /opt
$ python3 -m venv py3
$ source /opt/py3/bin/activate
# 看到下面的提示符代表成功以后运行jumpserver都要先运行以上source命令以下所有命令均在该虚拟环境中运行
(py3) [root@localhost py3]#
```
### 二. 安装Jumpserver 0.5.0
**2.1 下载或clone项目**
项目提交较多git clone时较大你可以选择去github项目页面直接下载 zip包我的网速好我直接clone了
```
$ cd /opt/
$ git clone https://github.com/jumpserver/jumpserver.git && git checkout dev
```
**2.2 安装依赖rpm包**
```
$ cd /opt/
$ cd jumpserver/requirements
$ yum -y install $(cat rpm_requirements.txt) # 如果没有任何报错请继续
```
**2.3 安装python库依赖**
```
$ pip install -r requirements.txt # 如果没有任何报错请继续
```
**2.4 安装Redis, jumpserver使用celery依赖**
```
$ yum -y install redis
$ service redis start
```
**2.5 安装MySQL**
本教程使用mysql作为数据库如果不使用mysql可以跳过相关mysql安装和配置
```
# centos7
$ yum -y install mariadb mariadb-devel mariadb-server # centos7下安装的是mariadb
$ service mariadb start
# centos6
$ yum -y install mysql mysql-devel mysql-server
$ service mysql start
```
**2.6 创建数据库 jumpserver并授权**
```
$ mysql
> create database jumpserver default charset 'utf8';
> grant all on jumpserver.* to 'jumpserver'@'127.0.0.1' identified by 'somepassword';
```
**2.7 修改jumpserver配置文件**
```
$ cd /opt/jumpserver
$ cp config_example.py config.py
$ vi config.py # 我们计划修改 DevelopmentConfig中的配置因为默认jumpserver是使用该配置它继承自Config
```
```
class DevelopmentConfig(Config):
DEBUG = True
DB_ENGINE = 'mysql'
DB_HOST = '127.0.0.1'
DB_PORT = 3306
DB_USER = 'jumpserver'
DB_PASSWORD = 'somepassword'
DB_NAME = 'jumpserver'
EMAIL_HOST = 'smtp.exmail.qq.com'
EMAIL_PORT = 465
EMAIL_HOST_USER = 'a@jumpserver.org'
EMAIL_HOST_PASSWORD = 'somepasswrd'
EMAIL_USE_SSL = True
EMAIL_USE_TLS = False
EMAIL_SUBJECT_PREFIX = '[Jumpserver] '
SITE_URL = 'http://192.168.244.144:8080' # 用户收到的邮件,会使用该地址访问
```
**2.8 生成数据库表结构和初始化数据**
```
$ cd /opt/jumpserver/utils
$ bash make_migrations.sh
```
**2.9 运行Jumpserver**
```
$ cd /opt/jumpserver
$ python run_server.py
```
运行不报错,请浏览器访问 http://192.168.244.144:8080/
账号: admin
密码: admin
### 三. 安装 SSH Server和Web Socket Server: Coco
**3.1 下载clone项目**
新开一个终端,连接测试机,别忘了 source /opt/py3/bin/activate
```
$ cd /opt
$ git clone https://github.com/jumpserver/coco.git && git checkout dev
```
**3.2 安装依赖**
```
$ cd /opt/coco/requirements
$ yum -y install $(cat rpm_requirements.txt)
$ pip install -r requirements.txt
```
**3.3 查看配置文件并运行**
```
$ cd /opt/coco
$ cat config.py
$ python run_server.py
```
这时需要去 jumpserver管理后台-终端-终端(http://192.168.244.144:8080/terminal/terminal/)接受coco的注册
```
Coco version 0.4.0, more see https://www.jumpserver.org
Starting ssh server at 0.0.0.0:2222
Quit the server with CONTROL-C.
```
**3.4 测试连接**
```
$ ssh -p2222 admin@192.168.244.144
密码: admin
如果是用Xshell登录语法如下
$ssh admin@192.168.244.144 2222
密码: admin
如果能登陆代表部署成功
```
### 四. 安装 Web Terminal 前端: Luna
Luna已该为纯前端需要nginx来运行访问, 这里仅
**4.1 下载clone项目**
```
$ cd /opt
$ git clone https://github.com/jumpserver/luna.git
$ cd luna && npm install && ng build
```
### 五. 配置 nginx 整合各组件
5.1 安装nginx
根据喜好选择安装方式和版本
5.2 配置文件
```
server {
listen 80;
location /luna/ {
root /opt/luna/dist;
}
location /media/ {
add_header Content-Encoding gzip;
root /opt/jumpserver/data/media/;
}
location /static/ {
root /opt/jumpserver/data/static/;
}
location /socket.io/ {
proxy_pass http://localhost:5000/socket.io/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location / {
proxy_pass http://localhost:8080;
}
}
```
5.3 运行 nginx
5.4 访问 http://localhost