首先进入官网http://tomcat.apache.org/download-80.cgi下载ZIP文件。
1.安装tomcat8.0。
解压zip后,配置环境变量;
① 配置CATALINA_HOME CATALINA_BASE
CATALINA_HOME D:\apache-tomcat-8.0.51 CATALINA_BASE D:\apache-tomcat-8.0.51
② 配置JAVA_HOME
JAVA_HOME C:\Program Files\Java\jdk1.8.0_101
③ 配置CLASSPATH
CLASSPATH .;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar
④ Path下添加bin路径
%JAVA_HOME%\bin %JAVA_HOME%\jre\bin %CATALINA_HOME%\lib %CATALINA_HOME%\bin
2.安装tomcat服务
DOS 下进入tomcat/bin目录,执行如下语句:
service.bat install
Tomcat8安装服务图示如下:
3.启动Tomcat
cmd 进入命令窗口,直接输入 startup。
浏览器输入https://localhost:8080/,出现欢迎页面则安装成功!
4.配置Tomcat用户
修改Tomcat/conf下tomcat-users.xml
<tomcat-users xmlns="http://tomcat.apache.org/xml"
<tomcat-users xmlns="http://tomcat.apache.org/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd" version="1.0"> <!-- NOTE: By default, no user is included in the "manager-gui" role required to operate the "/manager/html" web application. If you wish to use this app, you must define such a user - the username and password are arbitrary. It is strongly recommended that you do NOT use one of the users in the commented out section below since they are intended for use with the examples web application. --> <!-- NOTE: The sample user and role entries below are intended for use with the examples web application. They are wrapped in a comment and thus are ignored when reading this file. If you wish to configure these users for use with the examples web application, do not forget to remove the <!.. ..> that surrounds them. You will also need to set the passwords to something appropriate. --> <role rolename="manager-gui"/> <role rolename="admin-gui"/> <role rolename="admin"/> <role rolename="manager"/> <user username="tomcat" password="tomcat" roles="manager-gui,admin-gui,admin,manager"/> </tomcat-users>
进入管理界面:
5.Tomcat8.exe和Tomcat8w.exe
Tomcat8.exe 是服务运行程序,也就是启动Tomcat服务,作用和startup.bat一样都能启动Tomcat服务,窗口关闭,服务访问终止。
其窗口如下:
Tomcat8w.exe 是图形化界面程序,作用是配置和监视tomcat的服务。
其窗口如下:
可以对Tomcat服务进行操作。
总结,有三种方式可以启动Tomcat服务。
① startup.bat
② tomcat8.exe
③ 计算机服务列表
前两种方式是窗口方式启动,窗口关闭,服务终止。前两种方式启动Tomcat不会影响计算机服务中Tomcat服务状态。
第三种方式就比较方便,在服务列表启动即可,无窗口显示。