- 查看主机支持的字符集
cat /etc/locale.conf
若是LANG="en_US.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
cat /etc/locale.conf
#查看修改结果
需要支持的mysql版本大于5.56,需要支持的Python3.6
#安装依赖包
yum -y install wget sqlite-devel xz gcc automake zlib-devel openssl-devel epel-release git
#安装Python3.6(下载过慢可更换epel源)
yum -y install python36 python36-devel
#或者下载源码包,编译安装Python3.6
cd /usr/local/src/
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
tar xf Python-3.6.1.tar.xz && cd Python-3.6.1
./configure && make && make install
#安装完成后查看Python3的版本
python3 -V
#创建一个py3的虚拟环境
cd /opt/
python3.6 -m venv py3
source /opt/py3/bin/activatecat
#使其立即生效,最左边出现(py3)提示符代表成功
运行jumpserver,必须运行以上source命令,以下所有命令,也要在该虚拟环境下运行
cd /opt/
git clone https://github.com/kennethreitz/autoenv.git
echo 'source /opt/autoenv/activate.sh' >> ~/.bashrc
source ~/.bashrc
#若克隆过程太长,可以用--depth 1参数,只下载最新的版本
cd /opt/
git clone --depth 1 https://github.com/jumpserver/jumpserver.git
#.env的作用是只要进入/opt/jumpserver/目录,就自动进入py3的环境中,首次进入目录需要确认,y即可
echo "source /opt/py3/bin/activate" > /opt/jumpserver/.env
cd jumpserver/
cd /opt/jumpserver/requirements/
yum -y install $(cat rpm_requirements.txt)
#依旧是在requirements目录下,先升级setup工具
pip install --upgrade pip setuptools -i https://mirrors.aliyun.com/pypi/simple/
#pip下载加速设置
cd /opt/jumpserver/
cd ~
mkdir .pip
vim ~/.pip/pip.conf
#加入以下内容:
[global]
index-url=https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
#继续下载依赖包
cd /opt/jumpserver/requirements/
pip install -r requirements.txt
#若下载卡在某个包,可以wget软件包,然后使用pip+instal+软件包名,然后将requirement.txt文件中对应的行注释,继续安装其他包,安装完成后检查步骤正确性
echo $?
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`
echo $DB_PASSWORD #需要摘记作为数据库用户的密码
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
BOOTSTRAP_TOKEN=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 16`
echo $BOOTSTRAP_TOKEN
#加入家目录下bash配置文件
echo "SECRET_KEY=$SECRET_KEY" >> ~/.bashrc
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
#初始化数据库,出现多项OK为正确
cd /opt/jumpserver/utils/
bash make_migrations.sh
#启动jumpserver并检查正确性,端口8080是否开启
cd /opt/jumpserver/
./jms start all -d
netstat -antup | grep 8080
运行后,可使用浏览器输入IP:8080访问jumpserver,初始默认账号密码均为admin
cd /opt/
git clone https://github.com/jumpserver/coco.git
echo "source /opt/py3/bin/activate" > /opt/coco/.env
cd coco/
#第一进入提示,y即可
cd /opt/coco/requirements/
yum -y install \$(cat rpm_requirements.txt)
#安装python的依赖
pip install -r requirements.txt
cd /opt/coco/
#可以看看目录下的东西
mkdir keys logs
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
cd /opt/coco
./cocod start -d
#检查启动情况,是否开启5000端口和2222端口
netstat -lntp
cd /opt/
wget https://github.com/jumpserver/luna/releases/download/1.4.9/luna.tar.gz
tar xf luna.tar.gz
chown -R root:root luna
yum -y install yum-utils
vim /etc/yum.repos.d/nginx.repo
#加入内容:
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
#安装nginx
yum -y install nginx
cd /etc/nginx/conf.d/
rm -f default.conf
vim jumpserver.conf
#加入以下内容,需要注意各模块的目录是否准确:
server {
listen 80;
client_max_body_size 100m;
location /luna/ {
try_files $uri / /index.html;
alias /opt/luna/;
}
location /media/ {
add_header Content-Encoding gzip;
root /opt/jumpserver/data/;
}
location /static/ {
root /opt/jumpserver/data/;
}
location /socket.io/ {
proxy_pass http://localhost:5000/socket.io/;
proxy_buffering off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log off;
}
location /coco/ {
proxy_pass http://localhost:5000/coco/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log off;
}
location /guacamole/ {
proxy_pass http://localhost:8081/;
proxy_buffering off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log off;
}
location / {
proxy_pass http://localhost:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
nginx -t
systemctl start nginx
systemctl enable nginx