2、CentOS 环境搭建
安装下载器
yum -y install wget
2.1、配置JDK
安装Java环境
yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel
配置环境变量
# 1.将下面的三行添加到 /etc/profile 中:
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
# 2.让设置立即生效。
source /etc/profile
# 3.查看java版本,检查是否安装成功
java -version
2.2、配置MySQL
安装MySQL
# 下载mysql
wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
# 把mysql添加到yum安装器
rpm -ivh mysql57-community-release-el7-7.noarch.rpm
# 安装mysql
yum install mysql-community-server
修改密码
# 1.修改配置文件
vim /etc/my.cnf
# 2.在symbolic-links=0上面添加skip-grant-tables,这时候登入mysql就不需要密码
skip-grant-tables
symbolic-links=0
# 3.重启mysql服务器
service mysqld restart
# 4.登录mysql,没有密码直接回车进入
mysql -u root -p
# 5.修改密码
set password for root@localhost = password('123456');
flush privileges;
set password for root@localhost = password('123456'); or update user set
authentication_string=PASSWORD("123456") where user="root";
flush privileges;
quit;
# 6.删除配置文件中添加的skip-grant-tables
# 7.重启服务器
service mysqld restart
# 8.开启mysql的远程访问
mysql -uroot -p root
use mysql;
update user set host = '%' where user ='root';
grant all privileges on *.* to 'root'@'%' with grant option;
flush privileges;
exit;
# 9.重启服务器
service mysqld restart
2.3、配置Tomcat
①下载Tomcat
wget https://mirrors.cnnic.cn/apache/tomcat/tomcat-8/v8.5.57/bin/apache-tomcat-8.5.57.tar.gz
②解压Tomcat
tar -xzvf apache-tomcat-8.5.57.tar.gz
③启动Tomcat
./apache-tomcat-8.5.57/bin/startup.sh
④开放8080端口
firewall-cmd --zone=public --add-port=8080/tcp --permanent
⑤重启防火墙使设置生效
firewall-cmd --reload