当前位置: 移动互联网学院 > Java培训 > JAVA开发 > JEESZ分布式架构搭建2-CentOs下安装Tomcat7(环境准备)
JEESZ分布式架构搭建2-CentOs下安装Tomcat7(环境准备) 时间:2017-05-11     来源:华清远见JAVA学院

之前分享过JEESZ分布式架构搭建教程第一部分-CentOs下安装jdk7(环境准备),今天分享第二部分,如何在CentOs下安装Tomcat7?

JEESZ分布式架构搭建2-CentOs下安装Tomcat7(环境准备)

 

1. 安装tomcat

通过ssh将apache-tomcat-7.0.61.tar.gz文件上传到/usr/local中执行以下操作:

[root@cloud /]cd /usr/local

[root@cloud /]tar -zxvfapache-tomcat-7.0.61.tar.gz

[root@cloud /]mv apache-tomcat-7.0.61 tomcat

2. 启动Tomcat

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

Using CATALINA_BASE: /usr/local/tomcat

Using CATALINA_HOME: /usr/local/tomcat

Using CATALINA_TMPDIR: /usr/local/tomcat/temp

Using JRE_HOME: /home/Java/jdk1.7/

Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

Tomcat started.

出现以上信息说明已成功启动。

3. 防火墙开放8080端口

[root@cloud /]vi + /etc/sysconfig/iptables

#增加以下代码

#Tomcat 8080

-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT

4. 重启防火墙

[root@cloud /]service iptables restart

5. 检验Tomcat安装运行

通过你自己的服务器IP查看tomcat是否运行正常:

//xxx.xxx.xxx.xxx:8080/

看到tomcat系统界面,说明安装成功!

6. 停止Tomcat

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

Using CATALINA_BASE: /usr/local/tomcat

Using CATALINA_HOME: /usr/local/tomcat

Using CATALINA_TMPDIR: /usr/local/tomcat/temp

Using JRE_HOME: /home/java/jdk1.7

Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

7. 查看启动、停止日志

[root@cloud ~]#cd /usr/local/tomcat/logs/

[root@cloud logs]# ls

catalina.2016-02-13.log catalina.out host-manager.2016-02-14.log localhost.2016-02-14.log localhost_access_log.2016-02-14.txt manager.2016-02-14.log

catalina.2016-02-14.log host-manager.2016-02-13.log localhost.2016-02-13.log localhost_access_log.2016-02-13.txt manager.2016-02-13.log

[root@cloud logs]# tail -f catalina.out

Feb 14, 2016 1:25:33 AMorg.apache.catalina.core.StandardService stopInternal

INFO: Stopping service Catalina

Feb 14, 2016 1:25:33 AM org.apache.coyote.AbstractProtocol stop

INFO: Stopping ProtocolHandler ["http-bio-8080"]

Feb 14, 2016 1:25:33 AM org.apache.coyote.AbstractProtocol stop

INFO: Stopping ProtocolHandler ["ajp-bio-8009"]

Feb 14, 2016 1:25:33 AM org.apache.coyote.AbstractProtocol destroy

INFO: Destroying ProtocolHandler ["http-bio-8080"]

Feb 14, 2016 1:25:33 AM org.apache.coyote.AbstractProtocol destroy

INFO: Destroying ProtocolHandler ["ajp-bio-8009"]

以上介绍了搭建JEESZ分布式架构2--CentOs下安装Tomcat7(环境准备)的一些教程,希望对Java教程有兴趣的朋友有所帮助。

X