Tomcat的安装及配置我曾经使用过tomcat,并实现了一个简单的servlet程序。没想到再次安装tomcat的时候用浪费了我大半天的时间。我想有必要做个总结,否则下次不知又要花费我多少时间。

1、 Tomcat下载

Tomcat是Apache开源工程的一个项目,因此我们可以去http://tomcat.apache.org/ tomcat官网去下最新版本的tomcat。目前最新的是Tomcat7.02,但是由于tomcat与jdk版本需要匹配(一般情况是jdk1.5对应tomcat5,jdk1.6对应tomcat6),保险起见还是选用用Tomcat6 。网址:http://tomcat.apache.org/download-60.cgi 问题来了,网站上提供了多种版本的tomcat,到底哪一款适合我呢?在网站提供的README文件中给出了各个版本的介绍如下:

apache-tomcat-[version].zip or .tar.gz

Base distribution. These distributions do not include the Windows service wrapper nor the compiled APR/native library for Windows.

apache-tomcat-[version].exe

32-bit/64-bit Windows installer for Tomcat. Please note that while this distribution includes the vast majority of the base distribution, some of the command-line scripts for launching Tomcat are not included. This distribution is intended for those users planning to launch Tomcat through the Windows shortcuts or services.

apache-tomcat-[version]-windows-x86.zip

32-bit Windows specific distribution that includes the Windows service wrapper and the compiled APR/native library for use with 32-bit JVMs on both 32 and 64 bit Windows platforms.

apache-tomcat-[version]-windows-x64.zip

64-bit Windows specific distribution that includes the Windows service wrapper and the compiled APR/native library for use with 64-bit JVMs on x64 Windows platforms.

apache-tomcat-[version]-windows-i64.zip

64-bit Windows specific distribution that includes the Windows service wrapper and the compiled APR/native library for use with 64-bit JVMs on Itanium 64-bit Windows platforms.

apache-tomcat-[version]-deployer.zip or .tar.gz

The standalone Tomcat Web Application Deployer. apache-tomcat-[version]-fulldocs.tar.gz The Tomcat documentation bundle, including complete javadocs.

一般情况我们选择apache-tomcat-[version]-windows-x86.zip 下载后直接解压至指定目录即可(我选择了C:\tomcat) 。当然我们只关心binary distributions就可以了,至于code版就看你个人学习激情了。

2、 tomcat 环境配置

配置Tomcat的环境变量:在“我的电脑”上点右键—>“属性”—>“高级”—> “环境变量(N)”。

1、新建系统变量CATALINA_HOME:C:\Tomcat(注意此后不要加分号)

2、新建系统变量TOMCAT_HOME:C:\Tomcat(好像是为了MyEclipse配置的)

3.在系统变量CLASSPATH的值的后面加入:CATALINA_HOME%\lib;(这个要加分号)

4、在系统变量Path的值的后面加入以下内容:CATALINA_HOME%\bin;f\方便用户运行tomcat的各种脚本:

5、在系统变量CLASSPATH的值的加入: CATALINA_HOME%\lib\servlet-api.jar;

3、 运行tomcat  直接运行startup.bat


个人建议用命令提示符程序(cmd.exe)运行C:\Tomcat\bin目录下的批处理文件(.bat)。如:注意要在当前目录下运行否则找不到 C:\Tomcat\bin> startup.bat install C:\Tomcat\bin> shutdown.bat install C:\Tomcat\bin> service.bat install 开启tomcat后可以用浏览器访问http://localhost:8080/ 如果出现tomcat的界面就说明你已经成功安装tomcat。

4、 tomcat账户设置

如果你选择的是exe安装文件,在安装过程中他会提示你输入用户名密码。

如果你用的是解压包形式的,则需要在CATALINA_HOME/conf/tomcat-users.xml文件中。编辑这个文件,可以修改用户名和密码,例如添加一个名叫“tomcat”的“manager”角色到该文件中:然后重新启动Tomcat。 登录时输入tomcat,密码tomcat即可。注意:rolename 只能是manager

5、 win7下tomcat6w.exe无法运行:

在windows7操作系统下,安装了tomcat6。双击tomcat6w.exe时,提示错误“Unable to open the service ‘tomcat6’”。解决方法一:此问题可能是windows 7的安全控制限制所致。在tomcat6w.exe文件上点击右键--属性--兼容性,勾选“以管理员身份运行此程序”,点击确定。然后双击运行即可;如果还不行见方法二。解决方法二:可能是没有安装此项服务。具体安装方法:打开命令行提示符窗口 => 进入Tomcat安装目录==> 进入bin目录下==> 输入:service.bat install 即可。如果还是不行,目前就不知道如何解决,还希望知道的大牛们给出本质的解决方案!(可能的原因由于网络端口独占不能两个tomcat同时运行)

6、tomcat.ext 与tomcat6.ext主要区别:

tomcat6.exe与tomcat6w.exe这两个都能启动tomcat,一个是提供dos界面的启动方式,一个是可视化的界面启动方式。但是呢tomcat6w.exe并不是用来启动tomcat的,而是用来配置tomcat在windows下的系统服务的。两个不能同时启动。

7.访问俄服务器8080端口时,在地址栏一定要输入"http"的完整形式,否则浏览器可能不会使用http协议去访问该端口。

最新文章

  1. 开源许可证GPL、BSD、MIT、Mozilla、Apache和LGPL的区别
  2. [leetcode 24] Swap Nodes in k-Group
  3. highchars
  4. 使用node.js抓取有路网图书信息(原创)
  5. C#学习笔记——面向对象、面向组件以及类型基础
  6. csdn博客刷点击率代码
  7. C#多线程(一)
  8. BZOJ_1096_[ZJOI2007]_仓库建设_(斜率优化动态规划+单调队列+特殊的前缀和技巧)
  9. Why Creating a Meaningful Morning Routine Will Make You More Successful
  10. PHP 实现无限极栏目分类
  11. Nodejs之发送邮件nodemailer
  12. 5天2亿活跃用户,QQ“LBS+AR”天降红包活动后台揭密
  13. SAP MM 明明有需求,为啥MRP RUN后没有PR单据产生?
  14. Fiddler对Android应用进行抓包
  15. postgresql从timestamp(6)复制到timestamp(0),时间会变
  16. 仿stl+函数模板
  17. 作业二:构建swap函数
  18. java.util (Collection接口和Map接口)
  19. Nginx的核心功能及应用实战
  20. Android 基于 Speex 的高度封装语音库,0 耦合,没三方jar包

热门文章

  1. apt-get update 问题 及gcc高亮
  2. 自定义custom Tab Bar
  3. 在msys里进行复制和粘贴操作
  4. vue 随笔3
  5. codeforces 724D
  6. Codechef QGRID
  7. hihoCoder扩展欧几里得
  8. 黑客攻防技术宝典web实战篇:核心防御机制习题
  9. ES6之箭头函数深入理解
  10. Codeforces Round #510 (Div. 2) A&B By cellur925