tomcat部署

本文介绍了在Linux服务器上部署Tomcat的步骤,包括Java环境的安装、Tomcat的下载与解压,以及如何启动相关服务,确保manager应用正常运行。
摘要由CSDN通过智能技术生成

tomcat部署

java环境安装
[root@localhost ~]# yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel
[root@localhost ~]# java -version
openjdk version "1.8.0_322"
OpenJDK Runtime Environment (build 1.8.0_322-b06)
OpenJDK 64-Bit Server VM (build 25.322-b06, mixed mode)
[root@localhost ~]# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# sed -i "s/=enforcing/=disabled/g" /etc/selinux/config
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce 0
Permissive
下载和解压tomcat
[root@localhost ~]# ls
anaconda-ks.cfg  apache-tomcat-9.0.65.tar.gz
[root@localhost ~]# tar xf apache-tomcat-9.0.65.tar.gz -C /usr/local/
[root@localhost ~]# cd /usr/local/
[root@localhost local]# ln -s apache-tomcat-9.0.65/ tomcat
[root@localhost local]# ll
total 0
drwxr-xr-x.  9 root  root  220 Aug 16 04:06 apache-tomcat-9.0.65
drwxr-xr-x.  2 root  root    6 Jun 22  2021 bin
drwxr-xr-x.  2 root  root    6 Jun 22  2021 etc
drwxr-xr-x.  2 root  root    6 Jun 22  2021 games
drwxr-xr-x.  2 root  root    6 Jun 22  2021 include
drwxr-xr-x.  2 root  root    6 Jun 22  2021 lib
drwxr-xr-x.  3 root  root   17 Aug 16 01:55 lib64
drwxr-xr-x.  2 root  root    6 Jun 22  2021 libexec
drwxr-xr-x.  2 root  root    6 Jun 22  2021 sbin
drwxr-xr-x.  5 root  root   49 Aug 16 01:55 share
drwxr-xr-x.  2 root  root    6 Jun 22  2021 src
lrwxrwxrwx.  1 root  root   21 Aug 16 04:07 tomcat -> apache-tomcat-9.0.65/
#测试页面
[root@localhost ~]# vim index.jsp
[root@localhost ~]# cat index.jsp 
<html>
<head>
        <title>test page</title>
</head>
<body>
        <%
            out.println("Hellow World");
        %>
</body>
</html>
[root@localhost ~]# mkdir /usr/local/tomcat/webapps/test
[root@localhost ~]# cp index.jsp /usr/local/tomcat/webapps/test/
[root@localhost ~]# ll /usr/local/tomcat/webapps/test/
total 4
-rw-r--r--. 1 root root 141 Aug 16 04:11 index.jsp
#开启tomcat服务 
[root@localhost ~]# /usr/local/tomcat/bin/catalina.sh start
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Using CATALINA_OPTS:   
Tomcat started.
[root@localhost ~]# ss -antl
State   Recv-Q  Send-Q        Local Address:Port     Peer Address:Port  Process  
LISTEN  0       128                 0.0.0.0:22            0.0.0.0:*              
LISTEN  0       1        [::ffff:127.0.0.1]:8005                *:*              
LISTEN  0       80                        *:3306                *:*              
LISTEN  0       100                       *:8080                *:*              
LISTEN  0       128                       *:80                  *:*              
LISTEN  0       128                    [::]:22               [::]:*            
添加环境变量
[root@localhost ~]# echo 'export PATH=/usr/local/tomcat/bin:$PATH' > /etc/profile.d/tomcat.sh
[root@localhost ~]# chmod +x /etc/profile.d/tomcat.sh
[root@localhost ~]# source /etc/profile.d/tomcat.sh

在这里插入图片描述
在这里插入图片描述

这个时候,很多服务还没开启,按照下面的步骤开启

#开启8009端口,调高与httpd连接的效率
[root@localhost conf]# pwd
/usr/local/tomcat/conf
[root@localhost conf]# vim server.xml
#取消注释
...
    <Connector protocol="AJP/1.3"
               address="::1"
               port="8009"
               redirectPort="8443" />
...

[root@localhost ~]# catalina.sh stop
  
[root@localhost ~]# catalina.sh start
#8009端口起来
[root@localhost conf]# ss -antl
State  Recv-Q Send-Q      Local Address:Port Peer Address:PortProcess 
LISTEN 0      128               0.0.0.0:22        0.0.0.0:*           
LISTEN 0      1      [::ffff:127.0.0.1]:8005            *:*           
LISTEN 0      100                 [::1]:8009         [::]:*           
LISTEN 0      80                      *:3306            *:*           
LISTEN 0      100                     *:8080            *:*           
LISTEN 0      128                     *:80              *:*           
LISTEN 0      128                  [::]:22           [::]:* 

在这里插入图片描述

启动Server status,设置登录名为tomcat,密码为tomcat
[root@localhost conf]# pwd
/usr/local/tomcat/conf
[root@localhost conf]# vim tomcat-users.xml
#添加
<role rolename="manager-gui"/>
<user username="tomcat" password="tomcat" roles="manager-gui"/>

[root@localhost META-INF]# ls
context.xml
[root@localhost META-INF]# vim context.xml
增加允许访问的网络
allow="192\.168\.192\.\d+|127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />

[root@localhost conf]# catalina.sh stop   
[root@localhost conf]# catalina.sh start

在这里插入图片描述

manager app的样式

在这里插入图片描述

#开启host manager
[root@localhost conf]# pwd
/usr/local/tomcat/conf
[root@localhost conf]# vim tomcat-users.xml
...
<role rolename="manager-gui"/>
<role rolename="admin-gui"/>
<user username="tomcat" password="tomcat" roles="manager-gui,admin-gui"/>
...
#放行ip
[root@localhost META-INF]# pwd
/usr/local/tomcat/webapps/host-manager/META-INF
[root@localhost META-INF]# vim context.xml 
allow="192\.168\.192\.\d+|127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />

[root@localhost conf]# catalina.sh stop   
[root@localhost conf]# catalina.sh start

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值