在Linux上部署Java开发环境笔记(三)
Linux中安装Tomcat6.0
2010/06/14
一、下载Tomcat6.0
下载地址:
http://apache.etoak.com/tomcat/tomcat-6/v6.0.26/bin/apache-tomcat-6.0.26.tar.gz
下载完文件为“apache-tomcat-6.0.26.tar.gz”
二、上传并解压缩
将“apache-tomcat-6.0.26.tar.gz”上传到/opt目录下
然后在shell下敲以下命令,解压缩:
tar -zxvf apache-tomcat-6.0.26.tar.gz
三、配置Tomcat环境
修改/etc/profile文件,在最后面添加如下2行:
export CATALINA_BASE=/opt/apache-tomcat-6.0.26
export CATALINA_HOME=/opt/apache-tomcat-6.0.26
重新登陆
检查环境变量是否设置OK
[root@localhost ~]# echo $CATALINA_BASE
/opt/apache-tomcat-6.0.26
[root@localhost ~]# echo $CATALINA_HOME
/opt/apache-tomcat-6.0.26
四、启动Tomcat服务
先检查下监听端口
[root@localhost bin]# netstat -nltp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 1712/smbd
tcp 0 0 0.0.0.0:6000 0.0.0.0:* LISTEN 1499/X
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1702/cupsd
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 1712/smbd
tcp 0 0 :::6000 :::* LISTEN 1499/X
tcp 0 0 :::22 :::* LISTEN 1766/sshd
可见tomcat还未启动,8080还未监听
接下来启动tomcat服务
[root@localhost bin]# $CATALINA_HOME/bin/startup.sh
Using CATALINA_BASE: /opt/apache-tomcat-6.0.26
Using CATALINA_HOME: /opt/apache-tomcat-6.0.26
Using CATALINA_TMPDIR: /opt/apache-tomcat-6.0.26/temp
Using JRE_HOME: /opt/jdk1.6.0_20
Using CLASSPATH: /opt/apache-tomcat-6.0.26/bin/bootstrap.jar
然后再检查下监听端口
[root@localhost bin]# netstat -nltp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 1712/smbd
tcp 0 0 0.0.0.0:6000 0.0.0.0:* LISTEN 1499/X
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1702/cupsd
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 1712/smbd
tcp 0 0 ::ffff:127.0.0.1:8005 :::* LISTEN 1980/java
tcp 0 0 :::8009 :::* LISTEN 1980/java
tcp 0 0 :::8080 :::* LISTEN 1980/java
tcp 0 0 :::6000 :::* LISTEN 1499/X
tcp 0 0 :::22 :::* LISTEN 1766/sshd
[root@localhost bin]# lsof -i :8080
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
java 1980 root 27u IPv6 8315 TCP *:webcache (LISTEN)
现在多了个8080端口!这个就是Tomcat的默认端口
五、测试Tomcat是否可用
在浏览器中打开
如果能看到Tomcat页面,证明Tomcat安装成功
如果还没看到,那就把防火墙关了:
[root@tpwb ~]# service iptables stop
至此,Linux下Tomcat6.0安装完毕