centos安装Tomcat

参考链接:https://blog.csdn.net/github_38336924/article/details/82253553

 

1、检查是否安装tomcat

    systemctl status tomcat

2、查看tomcat的相关信息

   yum info tomcat

[root@iZ2zebn3hsgwu61wulgeqhZ ~]# yum info tomcat
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Available Packages
Name        : tomcat
Arch        : noarch
Version     : 7.0.76
Release     : 9.el7_6
Size        : 91 k
Repo        : base/7/x86_64
Summary     : Apache Servlet/JSP Engine, RI for Servlet 3.0/JSP 2.2 API
URL         : http://tomcat.apache.org/
License     : ASL 2.0
Description : Tomcat is the servlet container that is used in the official Reference
            : Implementation for the Java Servlet and JavaServer Pages technologies.
            : The Java Servlet and JavaServer Pages specifications are developed by
            : Sun under the Java Community Process.
            : 
            : Tomcat is developed in an open and participatory environment and
            : released under the Apache Software License version 2.0. Tomcat is intended
            : to be a collaboration of the best-of-breed developers from around the world.

3、安装tomcat(默认安装路径是/usr/share/tomcat/

yum -y install tomcat

4、检查tomcat是否安装成功

[root@iZ2zebn3hsgwu61wulgeqhZ ~]# rpm -q tomcat
tomcat-7.0.76-9.el7_6.noarch

5、在配置文件中加入tomcat的环境变量(/etc/profile)

CATALINA_BASE=/usr/share/tomcat
CATALINA_HOME=/usr/share/tomcat
export JAVA_HOME PATH CLASSPATH CATALINA_BASE CATALINA_HOME

6、执行生效命令并查看tomcat变量

[root@iZ2zebn3hsgwu61wulgeqhZ etc]# source /etc/profile
[root@iZ2zebn3hsgwu61wulgeqhZ etc]# echo $CATALINA_BASE
/usr/share/tomcat
[root@iZ2zebn3hsgwu61wulgeqhZ etc]# 

7、开放8080端口 firewall-cmd --zone=public --add-port=8080/tcp --permanent

 

8、重启防火墙 

  systemctl restart firewalld.service

9、设置开机启动tomcat

  systemctl enable tomcat.service

[root@iZ2zebn3hsgwu61wulgeqhZ etc]# systemctl enable tomcat.service
Created symlink from /etc/systemd/system/multi-user.target.wants/tomcat.service to /usr/lib/systemd/system/tomcat.service.

10、安装根页面(tomcat-webapps)和Tomcat Web应用程序管理器和Virtual Host Manager(tomcat-admin-webapps)

yum install -y tomcat-webapps tomcat-admin-webapps 

11、安装在线文档(yum install -y tomcat-docs-webapp tomcat-javadoc)

12、安装成功后,检查目录是否存在

[root@iZ2zebn3hsgwu61wulgeqhZ etc]# cd /usr/share/tomcat/webapps
[root@iZ2zebn3hsgwu61wulgeqhZ webapps]# ll
total 24
drwxr-xr-x 14 root   root   4096 Mar 16 11:08 docs
drwxr-xr-x  8 tomcat tomcat 4096 Mar 16 11:07 examples
drwxr-xr-x  5 root   tomcat 4096 Mar 16 11:07 host-manager
drwxr-xr-x  5 root   tomcat 4096 Mar 16 11:07 manager
drwxr-xr-x  3 tomcat tomcat 4096 Mar 16 11:07 ROOT
drwxr-xr-x  5 tomcat tomcat 4096 Mar 16 11:07 sample

13、修改tomcat-users.xml的文件(vi /usr/share/tomcat/conf/tomcat-users.xml)

(1) 新增访问用户manager-guiadmin-gui

<tomcat-users>
   <user username="admin" password="password" roles="manager-gui,admin-gui"/>
</tomcat-users>

(2) 重启tomcat服务

sudo systemctl restart tomcat

14、访问8080端口

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值