分享

Centos7.2安装tomcat8.0

 紫怡辰星 2017-09-25

环境:腾讯云centos7.2

Tomcat8.0

1)首先在官网下载tomcat的安装包

安装的目录为/home/feifei/local/apache-tomcat-8.5.20

2)解压安装包

注意要在超级用户的模式下进行操作

su root

Password即可

# tar -zxvf apache-tomcat-8.5.20.tar.gz

3)配置环境变量

找到profile文件(上一篇,我已经写过如何找到profile文件并修改,这里不做解释)

profile文件的最后加上这样一句:TOMCAT_HOME=/home/feifei/local/apache-tomcat-8.5.20

4)将上一步配置生效(或重新登录)

# source /etc/profile

5)启动tomcat 

[root@199...../]#

 cd  /home/feifei/local/apache-tomcat-8.5.20/bin

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

最后出现Tomcat started.

说明成功开启
6)向防火墙添加8080端口

1.查看firewall的状态

[root@199..... ~]# firewall-cmd --state

Running表示在运行,not running没运行

若没有运行,可能是你的系统上没有安装防火墙

安装firewalld 防火墙  #yum install firewalld  

开启服务   # systemctl start firewalld.service

开机自动启动  # systemctl enable firewalld.service

再次输入# firewall-cmd --state时,running启动

2.添加8080端口

[root@199..... ~]# firewall-cmd --permanent --zone=public --add-port=8080/tcp

3.重新加载firewall

[root@199..... ~]# firewall-cmd --reload

7 测试tomcat在服务端是否能访问

[root@199...../]# curl http://localhost:8080

8如果不能正常访问可能是你的服务器安全组没有开着,经过一天的搜索,终于从一位大神那里找到答案 。。在控制面板那里把安全组中的全部端口放开,就可以正常使用了。

    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多