本文共 4076 字,大约阅读时间需要 13 分钟。
# cat /etc/redhat-releaseCentOS Linux release 7.5.1804 (Core)# uname -aLinux localhost.localdomain 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
# getenforce # 查看 SELINUX 状态,如果为 Enable,运行 `setenforce 0`Disabled# systemctl stop firewalld.service # 关闭防火墙
确保系统支持 UTF-8 加码:
# 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
# yum -y install wgetvim lrzsz xz gcc git epel-release python-pip python-devel mysql-devel automake autoconf sqlite-devel zlib-devel openssl-devel sshpass readline-devel
# 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
# cd /opt# python3.6 -m venv py3# source /opt/py3/bin/activate # 成功后提示符显示 `(py3)` 表示虚拟环境已激活
所有以 (py3) 表示的命令均在虚拟环境中运行。
# git clone --depth=1 https://github.com/jumpserver/jumpserver.git
# cd /opt/jumpserver/requirements# yum -y install $(cat rpm_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/
# pip install --upgrade pip setuptools# pip install -r requirements.txt
# yum -y install redis# systemctl enable redis# systemctl start redis
# yum -y install mariadb mariadb-devel mariadb-server# systemctl enable mariadb# systemctl start mariadb
# DB_PASSWORD=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 24`# mysql -uroot -e "create database jumpserver default charset 'utf8'; grant all on jumpserver.* to 'jumpserver'@'127.0.0.1' identified by '$DB_PASSWORD'; flush privileges;"
# cd /opt/jumpserver/# cp config_example.yml config.yml# SECRET_KEY=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 50`# echo "SECRET_KEY=$SECRET_KEY" >> ~/.bashrc# BOOTSTRAP_TOKEN=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 16`# 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
# cd /opt/jumpserver/# ./jms start all -d # 后台运行,带 `-d` 参数
# cd /opt# git clone --depth=1 https://github.com/jumpserver/coco.git
# cd /opt/coco/requirements# yum -y install $(cat rpm_requirements.txt)# pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
# cd /opt/coco/# cp config_example.yml config.yml# sed -i "s/BOOTSTRAP_TOKEN:/BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN/g" /opt/coco/config.yml# sed -i "s/# LOG_LEVEL: INFO/LOG_LEVEL: ERROR/g" /opt/coco/config.yml# ./cocod start -d # 后台运行,带 `-d` 参数
# wget https://github.com/jumpserver/luna/releases/download/1.4.10/luna.tar.gz# tar -xvf luna.tar.gz# chown -R root:root luna
# yum install yum-utils# vi /etc/yum.repos.d/nginx.repo# yum makecache fast# yum install -y nginx# rm -rf /etc/nginx/conf.d/default.conf# systemctl enable nginx
# vim /etc/nginx/conf.d/jumpserver.conf
# nginx -t# systemctl start nginx# systemctl enable nginx
# curl http://192.168.0.1 # Replace 以实际 IP 地址替换
$ ssh -p2222 admin@192.168.0.1密码: admin
$ ssh admin@192.168.0.1 2222密码: admin
通过以上步骤,Jumpserver 应用在 CentOS 7 环境下已成功部署完毕。
转载地址:http://okmjz.baihongyu.com/