tomcat部署

tomcat部署

安装jdk开发环境

[root@server2 ~]# yum -y install java-11-openjdk*

下载tomcat

[root@server2 ~]# wget https://archive.apache.org/dist/tomcat/tomcat-10/v10.0.12/bin/apache-tomcat-10.0.12.tar.gz

解压

[root@server2 ~]# tar xf apache-tomcat-10.0.12.tar.gz  -C /usr/local/
[root@server2 ~]# 
[root@server2 ~]# cd  /usr/local/
[root@server2 local]# ls
apache-tomcat-10.0.12  games    lib64    share
bin                    include  libexec  src
etc                    lib      sbin
[root@server2 local]# mv  apache-tomcat-10.0.12/ tomcat
[root@server2 local]# ls
bin  games    lib    libexec  share  tomcat
etc  include  lib64  sbin     src
[root@server2 local]# 

编写一个简单的网页

[root@server2 ~]# cat index.jsp
<html>
<head>
        <title>test page</title>
</head>
<body>
        <%
            out.println("Hellow World");
        %>
</body>
</html>

开启服务

[root@server2 tomcat]# /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@server2 tomcat]# ss -antl
State   Recv-Q  Send-Q          Local Address:Port                    Peer Address:Port                 
LISTEN  0       128                   0.0.0.0:22                           0.0.0.0:*                    
LISTEN  0       100                         *:8080                               *:*                    
LISTEN  0       128                         *:80                                 *:*                    
LISTEN  0       128                      [::]:22                              [::]:*                    
LISTEN  0       1          [::ffff:127.0.0.1]:8005                               *:*                    
[root@server2 tomcat]# 

访问网页

tomcat部署

移动网页

[root@server2 tomcat]# cd  webapps/
[root@server2 webapps]# ls
ROOT  docs  examples  host-manager  manager
[root@server2 webapps]# mv  ROOT/ /opt/
[root@server2 webapps]# mkdir ROOT
[root@server2 webapps]# cd
[root@server2 ~]# ls
YYDS                          etc
anaconda-ks.cfg               index.jsp
apache-tomcat-10.0.12.tar.gz  yyds
[root@server2 ~]# mv  index.jsp /usr/local/tomcat/webapps/ROOT/
[root@server2 ~]# 

访问网页

tomcat部署

配置文件

[root@server2 ~]# cd  /usr/local/tomcat/
[root@server2 tomcat]# ls
BUILDING.txt     README.md      conf  webapps
CONTRIBUTING.md  RELEASE-NOTES  lib   work
LICENSE          RUNNING.txt    logs
NOTICE           bin            temp
[root@server2 tomcat]# pwd
/usr/local/tomcat

[root@server2 webapps]# mkdir test
[root@server2 webapps]# ls
ROOT  docs  examples  host-manager  manager  test
[root@server2 webapps]# mv ROOT/insdex.jps  test/

设置用户和密码

[root@server2 conf]# vim tomcat-users.xml
[root@server2 conf]# pwd
/usr/local/tomcat/conf

.....
<role rolename="manager-gui"/>
<user username="tomcat" password="tomcat" roles="manager-gui"/>
.....

设置IP

[root@server2 manager]# pwd
/usr/local/tomcat/webapps/manager
[root@server2 manager]# vim  META-INF/context.xml 
........
<Context antiResourceLocking="false" privileged="true" >
  <CookieProcessor className="org.apache.tomcat.util.http.Rfc6265CookieProcessor"
                   sameSiteCookies="strict" />
  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="192\.168\.244\.\d+|127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />   #添加IP地址
  <Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
</Context>
.........

关闭服务

[root@server2 ~]# /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:        /usr
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Using CATALINA_OPTS:   
NOTE: Picked up JDK_JAVA_OPTIONS:  --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
[root@server2 ~]# ss -antl
State    Recv-Q   Send-Q       Local Address:Port                     Peer Address:Port                 
LISTEN   0        128                0.0.0.0:22                            0.0.0.0:*                    
LISTEN   0        128                      *:80                                  *:*                    
LISTEN   0        128                   [::]:22                               [::]:*                    
[root@server2 ~]# ps -ef | grep  tomcat
root      154340   26434  0 22:00 pts/2    00:00:00 grep --color=auto tomcat

启动服务

[root@server2 ~]# /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@server2 ~]# 
[root@server2 ~]# 
[root@server2 ~]# ss -antl
State   Recv-Q  Send-Q          Local Address:Port                    Peer Address:Port                 
LISTEN  0       128                   0.0.0.0:22                           0.0.0.0:*                    
LISTEN  0       100                         *:8080                               *:*                    
LISTEN  0       128                         *:80                                 *:*                    
LISTEN  0       128                      [::]:22                              [::]:*                    
LISTEN  0       1          [::ffff:127.0.0.1]:8005                               *:*                    
[root@server2 ~]# 

访问网页

tomcat部署
tomcat部署
tomcat部署

控制服务

tomcat部署
tomcat部署

访问test

tomcat部署

开启

tomcat部署
tomcat部署

上一篇:k8s pod 管理


下一篇:Zabbix分布式监控平台部署<3>--zabbix-nginx部署及字体修正