tomcat

文章目录

  • 1. tomcat项目部署
    • 1.1 java环境安装
    • 1.2 tomcat部署
  • 2. 开启管理模块

1. tomcat项目部署

1.1 java环境安装

//关闭防火墙和selinux
[root@tomcat ~]# systemctl stop firewalld
[root@tomcat ~]# systemctl disable firewalld
[root@tomcat ~]# setenforce 0

//安装jdk环境
[root@tomcat ~]# yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel

//查看安装的版本
[root@tomcat ~]# java -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-b12)
OpenJDK 64-Bit Server VM (build 25.131-b12, mixed mode)

1.2 tomcat部署

//下载tomcat
[root@tomcat ~]# cd /usr/src/
[root@tomcat src]# wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-9/v9.0.24/bin/apache-tomcat-9.0.24.tar.gz

//解压部署
[root@tomcat src]# ls
apache-tomcat-9.0.24.tar.gz  debug  kernels
[root@tomcat src]# tar xf apache-tomcat-9.0.24.tar.gz -C /usr/local/
[root@tomcat src]# cd /usr/local/
[root@tomcat local]# ln -s apache-tomcat-9.0.24/ tomcat
[root@tomcat local]# ll
总用量 0
drwxr-xr-x. 9 root root 220 8月  30 09:45 apache-tomcat-9.0.24
drwxr-xr-x. 2 root root   6 3月  10 2016 bin
drwxr-xr-x. 2 root root   6 3月  10 2016 etc
drwxr-xr-x. 2 root root   6 3月  10 2016 games
drwxr-xr-x. 2 root root   6 3月  10 2016 include
drwxr-xr-x. 2 root root   6 3月  10 2016 lib
drwxr-xr-x. 2 root root   6 3月  10 2016 lib64
drwxr-xr-x. 2 root root   6 3月  10 2016 libexec
drwxr-xr-x. 2 root root   6 3月  10 2016 sbin
drwxr-xr-x. 5 root root  49 3月  25 02:56 share
drwxr-xr-x. 2 root root   6 3月  10 2016 src
lrwxrwxrwx. 1 root root  21 8月  30 09:45 tomcat -> apache-tomcat-9.0.24/

//写一个hello world的java页面
[root@tomcat ~]# vim index.html
[root@tomcat ~]# cat index.jsp 


     test page


        <%
            out.println("Hello World");
        %>



[root@tomcat ~]# mkdir /usr/local/tomcat/webapps/test
[root@tomcat ~]#  cp index.jsp /usr/local/tomcat/webapps/test/
[root@tomcat ~]# ll /usr/local/tomcat/webapps/test/
总用量 4
-rw-r--r--. 1 root root 137 8月  30 09:50 index.jsp

//启动tomcat
[root@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
Tomcat started.

[root@tomcat ~]# ps -ef|grep tomcat
root       2172      1  1 09:54 pts/1    00:00:04 /usr/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start
root       2229   2043  0 10:02 pts/1    00:00:00 grep --color=auto tomcat

[root@tomcat ~]# ss -antl
State       Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN      0      128     *:22                  *:*                  
LISTEN      0      100    127.0.0.1:25                  *:*                  
LISTEN      0      100    :::8080               :::*                  
LISTEN      0      128    :::22                 :::*                  
LISTEN      0      100       ::1:25                 :::*                  
LISTEN      0      1        ::ffff:127.0.0.1:8005               :::*                  
LISTEN      0      100    :::8009               :::*         

2. 开启管理模块

//修改配置文件/usr/local/tomcat/conf/tomcat-users.xml
[root@tomcat ~]# cd /usr/local/tomcat/conf/
[root@tomcat conf]# ls
Catalina             jaspic-providers.xml  tomcat-users.xml
catalina.policy      jaspic-providers.xsd  tomcat-users.xsd
catalina.properties  logging.properties    web.xml
context.xml          server.xml
[root@tomcat conf]# vim tomcat-users.xml
//在最后一行添加



//修改配置文件/usr/local/tomcat/webapps/manager/META-INF/context.xml
[root@tomcat webapps]# cd manager/
[root@tomcat manager]# ls
images  index.jsp  META-INF  status.xsd  WEB-INF  xform.xsl
[root@tomcat manager]# cd META-INF/
[root@tomcat META-INF]# ls
context.xml
[root@tomcat META-INF]# vim context.xml 

     # 这里添加本机ip地址网段
  

//重启tomcat服务
[root@tomcat ~]# /usr/local/tomcat/bin/startup.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
Tomcat started.

tomcat_第1张图片
tomcat_第2张图片

//修改配置文件/usr/local/tomcat/conf/tomcat-users.xml
[root@tomcat ~]# cd /usr/local/tomcat/conf/
[root@tomcat conf]# ls
Catalina             jaspic-providers.xml  tomcat-users.xml
catalina.policy      jaspic-providers.xsd  tomcat-users.xsd
catalina.properties  logging.properties    web.xml
context.xml          server.xml
[root@tomcat conf]# vim tomcat-users.xml 




//修改配置文件/usr/local/tomcat/webapps/host-manager/META-INF/context.xml
[root@tomcat ~]# cd /usr/local/tomcat/webapps/
[root@tomcat webapps]# ls
docs      host-manager  jenkins.war  ROOT
examples  jenkins       manager      test
[root@tomcat webapps]# cd host-manager/
[root@tomcat host-manager]# ls
images  index.jsp  manager.xml  META-INF  WEB-INF
[root@tomcat host-manager]# cd META-INF/
[root@tomcat META-INF]# vim context.xml
//在allow后面接本机ip网段

    



//重启tomcat服务
[root@tomcat ~]# /usr/local/tomcat/bin/startup.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
Tomcat started.

验证
tomcat_第3张图片
tomcat_第4张图片

你可能感兴趣的:(tomcat)