Tomcat7的安装与配置

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协议去访问该端口。

posted on 2017-05-31 20:16 诀语尘定 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/iihcy/p/6925786.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值