Tomcat服务器

来源:互联网 发布:巴黎 知乎 编辑:程序博客网 时间:2024/05/17 01:29

Tomcat下载地址:http://tomcat.apache.org

建议:JDK1.4使用Tomcat 5.0.x系列    JDK 1.5使用Tomcat5.5.x系列  JDK1.6使用Tomcat6.0系列

windows下载.zip包,Linux下载.tar.gz包

不建议使用安装文件


Tomcat目录:

bin:存放启动和关闭Tomcat命令

conf:存放Tomcat的配置,所有Tomcat配置都在改目录下设置

lib:该目录放着Tomcat服务器的核心类库(jar文件)。如果需要扩展Tomcat功能,也可以将第三方类库复制到该目录下

logs:这是一个空目录,用于保存Tomcat每次运行时产生的日志

temp:保存Web应用运行过程中生成的临时文件

webapps:该目录自动部署web应用,将web应用复制到该目录下,Tomcat会将该应用自动部署在容器中

work:保存web应用运行过程中生成的.class文件。该文件夹可以删除,但每次启动Tomcat服务器时,系统将再次建立该目录

LICENSE 等相关文档


运行Tomcat 需要环境变量 JAVA_HOME 变量值为JDK安装路径


启动Tomcat 双击bin目录中的srartup.bat即可


访问路径:localhost:8080



配置Tomcat的服务端口

默认端口为:8080

打开conf下的server.xml文件.找到以下代码

<Connector port="8080" protocol=”HTTP/1.1“

connectionTimeout=”20000“

redirectPort=”8443“/>

将8080改为任意端口,建议使用1024以上端口,避免冲突

提醒:修改后必须重启Tomcat


Tomcat控制台

右上角

一个是Status控制台,用于监控web运用状态

一个是Manager控制台,用于部署,监控web应用

我们通常使用Manager控制台


配置登陆

打开conf目录下的tomcat-usrs.xml

修改代码为

<?xml version='1.0' encoding='utf-8'?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at


      http://www.apache.org/licenses/LICENSE-2.0


  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<tomcat-users>
<!--
  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.
-->
<!--
  NOTE:  The sample user and role entries below are wrapped in a comment
  and thus are ignored when reading this file. Do not forget to remove
  <!.. ..> that surrounds them.
-->


  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <user username="tomcat" password="tomcat" roles="tomcat"/>
  <user username="both" password="tomcat" roles="tomcat,role1"/>
  <user username="role1" password="tomcat" roles="role1"/>
<role rolename="manager-gui"/>
<user username="tomcat" password="tomcat" roles="manager-gui"/>

</tomcat-users>

即可用用户名tomcat 密码tomcat登陆


原创粉丝点击