详解在Linux虚拟机下配置tomcat

1、到Apache官网下载tomcat

我下载的是tomcat8

jdk是1.8

如果你们的jdk是1.7或者1.7以下的就下载tomcat6或者tomcat7

详解在Linux虚拟机下配置tomcat Linux 第1张

2、把下载好的tomcat上传到Linux虚拟机下

详解在Linux虚拟机下配置tomcat Linux 第2张

3、去到tomcat所在的目录下解压压缩包

我的tomcat在/software目录下

解压命令:tar xzvf apache-tomcat-8.5

详解在Linux虚拟机下配置tomcat Linux 第3张

解压好后会多出一个文件

输入命令:ll

查看目录

详解在Linux虚拟机下配置tomcat Linux 第4张 

接下来可以把我们的压缩包删除了

输入命令:

  rm Cf apache-tomcat-8.5.9.tar.gz  

详解在Linux虚拟机下配置tomcat Linux 第5张

4、去到tomcat下的bin目录启动tomcat

输入命令:

  cd apache-tomcat-8.5.9/bin

启动tomcat命令:

  ./startup.sh

详解在Linux虚拟机下配置tomcat Linux 第6张 

查看所有进程看tomcat是否启动了

输入命令:

  ps -ef

详解在Linux虚拟机下配置tomcat Linux 第7张 

进程太多了,查看不方便的话,我们可以创建一个文本文件保存所有进程

输入命令:

  ps -ef >/software/ps.txt

详解在Linux虚拟机下配置tomcat Linux 第8张

详解在Linux虚拟机下配置tomcat Linux 第9张

详解在Linux虚拟机下配置tomcat Linux 第10张 

筛选我们想要的进程,例如:我想筛选出带java的进程

输入命令:

  ps -ef | grep java

详解在Linux虚拟机下配置tomcat Linux 第11张 

当我们需要关闭tomcat时

关闭tomcat命令:

  ./shutdown.sh

详解在Linux虚拟机下配置tomcat Linux 第12张 

5、服务器检查tomcat通不通时,我们需要安装一个Telnet

输入命令:

  yum install telnet

要确保你的网络通

输入y同意安装

详解在Linux虚拟机下配置tomcat Linux 第13张 

安装完成

详解在Linux虚拟机下配置tomcat Linux 第14张 

在Linux虚拟机下测试tomcat通不通,首先要把tomcat启动先

输入命令:telnet IP地址 8080

下面是tomcat测试通的情况

详解在Linux虚拟机下配置tomcat Linux 第15张 

Tomcat测试不通的情况是这样的

详解在Linux虚拟机下配置tomcat Linux 第16张 

如何查看自己的端口

详解在Linux虚拟机下配置tomcat Linux 第17张 

打开server文件查看

详解在Linux虚拟机下配置tomcat Linux 第18张 

 6、 客户端检查tomcat通不通,也要安装一个Telnet的客户端

详解在Linux虚拟机下配置tomcat Linux 第19张

详解在Linux虚拟机下配置tomcat Linux 第20张

在window系统下调试下IP地址通不通

输入命令:ping IP地址

详解在Linux虚拟机下配置tomcat Linux 第21张 

在window系统下用Telnet命令调试下Linux虚拟机的tomcat通不通

输入命令:telnet IP地址 8080

详解在Linux虚拟机下配置tomcat Linux 第22张 

连接失败是因为我们Linux有防火墙

这时我们把Linux虚拟机的防火墙关闭就可以了

输入命令:

  systemctl stop firewalld.service

详解在Linux虚拟机下配置tomcat Linux 第23张 

Window系统在测试一下能不能连上

详解在Linux虚拟机下配置tomcat Linux 第24张 

OK,我们可以连上了

7、我们写一个JSP页面调试一下

详解在Linux虚拟机下配置tomcat Linux 第25张 

Tomcat的默认目录是webapps

我们进去看一下

详解在Linux虚拟机下配置tomcat Linux 第26张 

里面有五个文件

详解在Linux虚拟机下配置tomcat Linux 第27张 

我们把除开ROOT的其他没必要的文件删了,ROOT文件是tomcat默认的项目文件。

为了方便,我直接在winscp上把其他文件删除了,只留下一个ROOT文件

详解在Linux虚拟机下配置tomcat Linux 第28张 

我们在window系统用页面访问,它会默认跳到ROOT项目,这个项目的首页就是apache的网站

详解在Linux虚拟机下配置tomcat Linux 第29张

接着把我们刚刚写好的JSP页面上传到ROOT文件里面

详解在Linux虚拟机下配置tomcat Linux 第30张 

我们用网页打开test.jsp

详解在Linux虚拟机下配置tomcat Linux 第31张 

我们看下控制台输出没

查看tomcat控制台,跟踪日志文件

首先要去到tomcat文件下的logs文件下

详解在Linux虚拟机下配置tomcat Linux 第32张 

输入命令:tail -f  catalina.out

详解在Linux虚拟机下配置tomcat Linux 第33张 

8、总结

可以看到我们后台输出了abc

这样我们就在Linux虚拟机下配置好我们的tomcat了

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

参与评论