2025年3月22日 星期六 甲辰(龙)年 月廿一 设为首页 加入收藏
rss
您当前的位置:首页 > 计算机 > 服务器 > Tomcat

Tomcat:基础安装和使用教程

时间:03-15来源:作者:点击数:46

背景

此文记录了 Tomcat 的基本使用方法,主要为了强化记忆。

安装步骤

第一步:下载和安装 Java

下载地址:http://www.oracle.com/technetwork/java/javase/downloads/index.html

安装并设置JAVA_HOME环境变量:

第二步:下载和解压 Tomcat

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

第三步:修改端口号

.NET 我使用的是 80xx,Php 我使用的是 81xx,Java 我使用的是 82xx。

修改D:\apache-tomcat-8.0.0-RC3\conf\server.xml:

  • <Service name="Catalina">
  • <!--The connectors can use a shared executor, you can define one or more named thread pools-->
  • <!--
  • <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
  • maxThreads="150" minSpareThreads="4"/>
  • -->
  • <!-- A "Connector" represents an endpoint by which requests are received
  • and responses are returned. Documentation at :
  • Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
  • Java AJP Connector: /docs/config/ajp.html
  • APR (HTTP/AJP) Connector: /docs/apr.html
  • Define a non-SSL HTTP/1.1 Connector on port 8080
  • -->
  • <Connector port="8200" protocol="HTTP/1.1"
  • connectionTimeout="20000"
  • redirectPort="8443" />

第四步:测试 Tomcat

运行:D:\apache-tomcat-8.0.0-RC3\bin\startup.bat,如果窗口没有立即关闭,就代表成功了。

第五步:发布自己的网站

最简单的发布方式莫过于将网站直接拷贝到:D:\apache-tomcat-8.0.0-RC3\webapps,这里介绍另外一种方式。

在D:\apache-tomcat-8.0.0-RC3\conf\Catalina\localhost下面建立一个naming.xml文件,内容如下:

  • <Context docBase="E:\Workspaces\Naming\1\WebRoot" debug="0" privileged="true">
  • </Context>

效果:

第六步:管理 Web App

 当点击 Manager App 的时候,会要求输入用户名和密码,可以在 D:\apache-tomcat-8.0.0-RC3\conf\tomcat-users.xml 中增加用户名,如下:

  • <?xml version='1.0' encoding='utf-8'?>
  • <tomcat-users>
  • <role rolename="manager-gui"/>
  • <user username="admin" password="123456" roles="manager-gui"/>
  • </tomcat-users>

注意:这是因为 Tomcat 支持 JAAS。

备注

Tomcat 蛮舒服的,心底里还是喜欢 IIS。

方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门