Linux(centos6.8)配置Tomcat环境

Posted HOsystem

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux(centos6.8)配置Tomcat环境相关的知识,希望对你有一定的参考价值。

1.下载Linux版的Tomcat包

(1)通过官方下载

tomcat官方:https://tomcat.apache.org/download-80.cgi

 

(2)通过分享下载

  如网盘分享等途径

2.将Tomcat放到Linux

(1)安装VMTools

(2)共享文件夹

(3)放入Tomcat文件

(4)复制Tomcat.tar到/opt

[root@pluto 桌面]# cd /mnt/hgfs/VMShare/

[root@pluto VMShare]# ll

总用量 440352

-rwxrwxrwx. 1 root root   8924465 12月  7 2019 apache-tomcat-7.0.70.tar.gz

-rwxrwxrwx. 1 root root 287110893 12月  7 2019 eclipse-jee-mars-2-linux-gtk-x86_64.tar.gz

-rwxrwxrwx. 1 root root 153512879 12月  7 2019 jdk-7u79-linux-x64.gz

-rwxrwxrwx. 1 root root   1364993 10月  8 2015 redis-3.0.4.tar.gz

[root@pluto VMShare]# cp apache-tomcat-7.0.70.tar.gz /opt

(5)解压Tomcat

[root@pluto VMShare]# cd /opt

[root@pluto opt]# ls -l

[root@pluto opt]# tar -zxvf apache-tomcat-7.0.70.tar.gz

[root@pluto opt]# ls -l

3.启动Tomcat

[root@pluto opt]# cd apache-tomcat-7.0.70/bin/

[root@pluto bin]# ls

bootstrap.jar                 daemon.sh         startup.sh

catalina.bat                  digest.bat        tomcat-juli.jar

catalina.sh                   digest.sh         tomcat-native.tar.gz

catalina-tasks.xml            setclasspath.bat  tool-wrapper.bat

commons-daemon.jar            setclasspath.sh   tool-wrapper.sh

commons-daemon-native.tar.gz  shutdown.bat      version.bat

configtest.bat                shutdown.sh       version.sh

configtest.sh                 startup.bat

[root@pluto bin]# ./startup.sh

Using CATALINA_BASE:   /opt/apache-tomcat-7.0.70

Using CATALINA_HOME:   /opt/apache-tomcat-7.0.70

Using CATALINA_TMPDIR: /opt/apache-tomcat-7.0.70/temp

Using JRE_HOME:        /opt/jdk1.7.0_79

Using CLASSPATH:       /opt/apache-tomcat-7.0.70/bin/bootstrap.jar:/opt/apache-tomcat-7.0.70/bin/tomcat-juli.jar

Tomcat started.

4.测试Tomcat是否配置成功

[1]内网访问

 

[2]外网访问

1]设置防火墙策略

[root@pluto bin]# vim /etc/sysconfig/iptables

 

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

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

 

#情况1

[root@pluto 桌面]# service iptables restart

iptables:将链设置为政策 ACCEPTfilter                    [确定]

iptables:清除防火墙规则:                                 [确定]

iptables:正在卸载模块:                                   [确定]

iptables:应用防火墙规则:                                 [确定]

[root@pluto 桌面]# service iptables status

 

#情况2

[root@pluto bin]# service iptables restart

iptables:将链设置为政策 ACCEPTfilter                    [确定]

iptables:清除防火墙规则:                                 [确定]

iptables:正在卸载模块:                                   [确定]

iptables:应用防火墙规则:iptables-restore v1.4.7: Bad state "-m"

Error occurred at line: 10

Try `iptables-restore -h\' or \'iptables-restore --help\' for more information.

                                                           [失败]

#出现以上错误运行下列代码

[root@pluto bin]# /etc/rc.d/init.d/iptables save

iptables:将防火墙规则保存到 /etc/sysconfig/iptables:     [确定]

[root@pluto bin]# /etc/init.d/iptables restart

iptables:将链设置为政策 ACCEPTfilter                    [确定]

iptables:清除防火墙规则:                                 [确定]

iptables:正在卸载模块:                                   [确定]

iptables:应用防火墙规则:                                 [确定]

 

 

运行结果:

 

 

注:如果出现restart错误,https://blog.csdn.net/zxl2016/article/details/89284003

2]通过Windows访问Linux

(1)获取开启Tomcat主机的ip

[root@pluto 桌面]# ifconfig

 

(2)Linux访问

 

(3)Windows访问

注:如果windows想访问linux中的tomcat,如果访问失败,则把防火墙关闭或者按照上面配置方法配置防火墙即可

http://192.168.188.188:8080/

参考文档:https://tomcat.apache.org/download-80.cgi

以上是关于Linux(centos6.8)配置Tomcat环境的主要内容,如果未能解决你的问题,请参考以下文章

Linux CentOS6.8 项目部署脚本实现

CentOS6.8启动Tomcat无法访问

阿里云centos6.8怎么优化tomcat内存

2.Linux环境下配置Solr4.10.3

linux centos6.8系统配置网络yum源

Linux Centos6.8 安装配置MongoDB-3.4.0