Apache Tomcat基础知识(二) 下载和安装tomcat

2014-02-06 11:23

此篇为Apache Tomcat基础知识的第一章,下载和安装Tomcat,Tomcat的安装是非常的简单.重点讲述在Linux(CentOS)下的安装,如果您对此章没有兴趣 。那么你可以选择此系统的目录 http://www.cnblogs.com/tomaer/articles/1923317.html 选择行的阅读

 

下载和安装Tomcat

Tomcat 是跨平台的. 而且有免安装版本.也就是说解压就可以使用,当然前提条件是你安装了 JDK 或者JRE,本篇中将不在讲述如何安装JDK.如果你还不会安装JDK,请查看 http://www.cnblogs.com/tomaer/articles/1924335.html

这里我们选择免安装版本,下载目录:http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.29/bin/ ,这个目录里面列出了很多.在写此章之前。我还不知道原来有Windows 64位版.后面的系列中提到的下载地址为:

     http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.29/bin/apache-tomcat-6.0.29.zip    (Windows platform)

     http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.29/bin/apache-tomcat-6.0.29.tar.gz  (Unix/Linux platform)

Remark: 

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.

 

Unix/Linux platform Install Apache Tomcat 6.0.29

打开终端,或者打开putty或者别的ssh工具.连接到CentOS.使用命令wget 下载即

[root@localhost ~]#wget http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.29/bin/apache-tomcat-6.0.29.tar.gz

当出现 'apache-tomcat-6.0.29.tar.gz' saved [6407210/6407210] 说明下载成功了,可以在终端输入ls查看命令确认一下是否下载完成
接着下来输入以下几条命令

[root@localhost ~]#mv apache-tomcat-6.0.29.tar.gz /home   ##将下载的tomcat软件包移动到/home目录下面

[root@localhost ~]#tar -zxvf /home/apache-tomcat-6.0.29.tar.gz -C /usr/local/  ##解压缩tomcat软件到/usr/local目录下面

[root@localhost ~]#mv /usr/local/apache-tomcat-6.0.29 /usr/local/tomcat  ##修改apache-tomcat-6.0.29的名字为tomcat,注意目录路径

小提示:上面第3条命令也可以改成做软链的方式.类似Windows下的快捷方式,命令如下:

[root@localhost ~]#ln -s /usr/local/apache-tomcat-6.0.29 /usr/local/tomcat  ##将apache-tomcat-6.0.29做个快捷方式

tomcat在Unix/Linux 平台下需要设置一下环境变量,方法如下:

1.用vi编辑器编辑/etc/profile(Linux主环境配置)文件,在最后加入2行

  TOMCAT_HOME=/usr/local/tomcat

  export PATH TOMCAT_HOME

2.source /etc/profile 使配置文件及时生效,也可以重新启动系统(reboot) 
安装到这里就结束了.

[root@localhost ~]#/usr/local/tomcat/bin/startup.sh & ##以后台进程的方式启动tomcat

要停止tomcat,可以使用下面命令

[root@localhost ~]#/usr/local/tomcat/bin/shutdown.sh

 

当出现下面的响应时,说明已经成功启动或者终止了tomcat,按下ctrl+c(释放终端) 注:终止tomcat会自动释放终端

[root@localhost ~]#/usr/local/tomcat/bin/startup.sh &


[root@localhost ~]# Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr/java/jdk1.6.0_23
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar

在浏览器上键入http://ip:8080/ 出现tomcat的页面则说明一切就绪


Windows platform Install Apache Tomcat 6.0.29

此文中给出了windows平台的下载地址,相对于unix/linux平台来讲,windows平台安装tomcat就一步.解压缩即可.假设目录为F:\apache-tomcat-6.0.29,之后我们将这个目录称为tomcat主目录。

启动tomcat,进入tomcat主目录下面的bin目录,双击startup.bat即可,停止tomcat双击shutdown.bat即可

在浏览器上键入http://ip:8080/ 出现tomcat的页面则说明一切就绪