堡垒机开发部署

一、环境配置

1、安装必要工具

yum -y install wget net-tools git python-pip mysql-devel rpm-build gcc automake autoconf python-devel vim sshpass lrzsz readline-devel make

2、安装依赖库

yum -y install epel-release openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel python-pip

3、cd /opt/ ,下载python3.6.4包 并解压

wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz
tar -zxvf Python-3.6.4.tgz

4、把python移到/usr/local下面

mv Python-3.6.4 /usr/local

5、进入python目录

cd /usr/local/Python-3.6.4/
# 配置
./configure

# 编译 安装
make && make install

6、查看旧版本的python依赖 并删除 python

ll /usr/bin | grep python
rm -rf /usr/bin/python

7、创建新的python软连接

ln -s /usr/local/bin/python3.6 /usr/bin/python

8、创建新的pip软连接

安装pip2

https://sites.google.com/a/cnsrl.cycu.edu.tw/da-shu-bi-ji/solve-bug/errorpip27commandnotfound

# 删除旧连接
rm -rf /usr/bin/pip
# 创建新连接
ln -s /usr/local/bin/pip3.6 /usr/bin/pip

9、修改yum相关文件

# 把    #!/usr/bin/python  改成
       #!/usr/bin/python2.7
vim /usr/bin/yum
vim /usr/libexec/urlgrabber-ext-down

9-1、验证

python -V  #Python 3.6.4
python2 -V #Python 2.7.5

pip -V #pip 19.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
pip2 -V #pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)

10、配置mysql数据库

下载mysql源安装包
wget http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

安装mysql源
yum localinstall mysql57-community-release-el7-11.noarch.rpm

检查mysql源是否安装成功
yum repolist enabled | grep "mysql.*-community.*"

安装MySQL
yum install mysql-community-server

查看已安装的mysql
yum list installed | grep mysql

启动MySQL服务
systemctl start mysqld

查看MySQL的启动状态以验证
systemctl status mysqld

设置开机启动
systemctl enable mysqld
systemctl daemon-reload

下面的方式找到root默认密码,然后登录mysql进行修改:
grep 'temporary password' /var/log/mysqld.log

修改root本地登录密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'mysql123';

开启mysql的远程登录
mysql> grant all privileges on *.* to 'root' @'%' identified by 'mysql123';
mysql> flush privileges;

设置默认编码为utf8
修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,如下所示:
vim /etc/my.cnf
===================
[mysqld]
character-set-server=utf8

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8
=====================

重启mysql
systemctl restart mysqld        

关闭firewall
systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl mask firewalld.service

安装iptables防火墙
yum install iptables-services -y

查看防火墙状态
systemctl status iptables

vim /etc/sysconfig/iptables #编辑防火墙配置文件
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8000 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

systemctl restart iptables.service #重启防火墙使配置生效
systemctl enable iptables.service #设置防火墙开机启动

调试3306端口是否能登陆上去
使用命令:
iptables -L -n

二、详细项目

项目代码

你可能感兴趣的:(堡垒机开发部署)