前言
小菜好多次装环境了,都忘了写博客。这次一定要记下来和大家分享。
yum方式安装JDK
"*"表示将java-1.8.0的所有相关Java程序都安装上(是不是很方便快捷)
[root@test ~]# yum -y install java-1.8.0-openjdk*
查看是否安装成功java -version(出现版本号代表安装成功)
[root@test ~]# java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-b04)
OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode)
安装tomcat
1.将tomcat安装在usr/lcoal下一般软件安装处
将入其文件夹
[root@test ~]# cd /usr/local
2.去tomcat官网复制你想下载的版本下载链接。注意一定要选择tar.gz这是liunx下的安装包,比如链接:http://mirror.bit.edu.cn/apache/tomcat/tomcat-9/v9.0.19/bin/apache-tomcat-9.0.19.tar.gz
3.wget命令下载安装包
[root@test ~]# wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-9/v9.0.19/bin/apache-tomcat-9.0.19.tar.gz
4.查看
[root@instance-wi0t3arq local]# ls
5.解压
个人习惯喜欢把安装包改一下名字
[root@instance-wi0t3arq local]# mv apache-tomcat-9.0.19.tar.gz tomcats
[root@instance-wi0t3arq local]# tar -zxvf tomcats
[root@instance-wi0t3arq local]# mv apache-tomcat-9.0.19 tomcat
6.查看是否安装成功
进入tomcat bin目录启动Tomcat(显示Tomcat started.则启动成功)
[root@instance-wi0t3arq local]# cd tomcat
[root@instance-wi0t3arq tomcat]# cd bin
[root@instance-wi0t3arq bin]# ./startup.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
用curl命令测试本地能不能访问8080端口
[root@instance-wi0t3arq bin]# curl http://localhost:8080
出现页面代码表示tomcat安装成功
7.启动远程访问(不要瞎改配置这只会让你陷入死循环。按照这三步来一点问题都没有)
a.关闭防火墙并关机禁止启动
[root@instance-wi0t3arq bin]# systemctl stop firewalld
[root@instance-wi0t3arq bin]# systemctl status firewalld
?firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
[root@instance-wi0t3arq bin]# systemctl disable firewalld
b.安全组配置8080端口(这个去云服务商网站配置一下就ok了)
c.重启tomcat
然后在你的浏览器里输入ip+:8080就可以访问到tomcat界面了
安装mysql
1.准备
# 下载mysql源安装包
[root@instance-wi0t3arq bin]# wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
# 安装mysql源
[root@instance-wi0t3arq bin]# yum localinstall mysql57-community-release-el7-8.noarch.rpm
检查mysql源是否安装成功
//不出现错误信息代表安装成功
[root@instance-wi0t3arq bin]# yum repolist enabled | grep "mysql.*-community.*"
2、安装MySQL
[root@instance-wi0t3arq bin]# yum install mysql-community-server
3、启动MySQL服务
[root@instance-wi0t3arq bin]# systemctl start mysqld
4.查看MySQL的启动状态
[root@instance-wi0t3arq bin] systemctl status mysqld
5.登录mysql修改本地登录密码
查看本机密码
[root@instance-wi0t3arq bin] grep 'temporary password' /var/log/mysqld.log
登录修改密码:注意此处密码一定要按照此格式来因为有验证规则。
[root@instance-wi0t3arq local]# mysql -u root -p
Enter password:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
6.开启远程连接
a.配置安全组3306端口
b.开启远程访问
mysql > GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'fanggus@1s23' WITH GRANT OPTION;
远程连接一下即可连接。
出现其他问题
1.本机版本与我的不一致我的linux内核版本是:centos7.5(换一下系统)
2.系统本身存在jdk、tomcat、mysql(重装)
3.如果系统不是第一次使用,建议重装系统这样不至于出现覆盖现象。如果不方便重装的话,就先将本机的jdk、mysql、tomcat卸载。
检索命令:
[root@test ~]# yum list installed |grep java
查看版本命令:
java -version
移除命令
yum -y remove java-1.7.0-openjdk*
嗯哼,通过这三个命令移除吧