Tomcat简介
Tomcat是Apache 软件基金会(Apache Software Foundation)的Jakarta 项目中的一个核心项目,由Apache、Sun 和其他一些公司及个人共同开发而成。由于有了Sun 的参与和支持,最新的Servlet 和JSP 规范总是能在Tomcat 中得到体现,Tomcat 5支持最新的Servlet 2.4 和JSP 2.0 规范。因为Tomcat 技术先进、性能稳定,而且免费,因而深受Java 爱好者的喜爱并得到了部分软件开发商的认可,成为目前比较流行的Web 应用服务器。
Tomcat 服务器是一个免费的开放源代码的Web 应用服务器,属于轻量级应用服务器,在中小型系统和并发访问用户不是很多的场合下被普遍使用,是开发和调试JSP 程序的首选。对于一个初学者来说,可以这样认为,当在一台机器上配置好Apache 服务器,可利用它响应HTML(标准通用标记语言下的一个应用)页面的访问请求。实际上Tomcat是Apache 服务器的扩展,但运行时它是独立运行的,所以当你运行tomcat 时,它实际上作为一个与Apache 独立的进程单独运行的。
Tomcat应用场景:lnmt
Tomcat项目部署
1.Java环境安装
安装jdk环境
[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_252"
OpenJDK Runtime Environment (build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)
2.Tomcat部署
下载Tomcat
[root@localhost ~]# cd /usr/src/
[root@localhost src]# ls
apache-tomcat-9.0.37.tar.gz debug kernels
解压部署
[root@localhost src]# tar xf apache-tomcat-9.0.37.tar.gz -C /usr/local/
[root@localhost src]# cd /usr/local/
[root@localhost local]# ln -s apache-tomcat-9.0.37/ tomcat
[root@localhost local]# ll
总用量 0
drwxr-xr-x. 9 root root 220 7月 30 18:08 apache-tomcat-9.0.37
drwxr-xr-x. 2 root root 6 11月 5 2016 bin
drwxr-xr-x. 2 root root 6 11月 5 2016 etc
drwxr-xr-x. 2 root root 6 11月 5 2016 games
drwxr-xr-x. 2 root root 6 11月 5 2016 include
drwxr-xr-x. 2 root root 6 11月 5 2016 lib
drwxr-xr-x. 2 root root 6 11月 5 2016 lib64
drwxr-xr-x. 2 root root 6 11月 5 2016 libexec
drwxr-xr-x. 2 root root 6 11月 5 2016 sbin
drwxr-xr-x. 5 root root 49 7月 3 19:02 share
drwxr-xr-x. 2 root root 6 11月 5 2016 src
lrwxrwxrwx. 1 root root 21 7月 30 18:08 tomcat -> apache-tomcat-9.0.37/
写一个hello world的Java界面
[root@localhost ~]# vim index.jsp
[root@localhost ~]# cat index.jsp
<html>
<head>
<title>test page</title>
</head>
<body>
<%
out.println("Hello World");
%>
</body>
</html>
[root@localhost ~]# mkdir /usr/local/tomcat/webapps/test
[root@localhost ~]# cd /usr/local/tomcat/webapps/test
[root@localhost test]# pwd
/usr/local/tomcat/webapps/test
[root@localhost test]# cp ~/index.jsp .
[root@localhost test]# ls
index.jsp
启动Tomcat
[root@localhost ~]# cd /usr/local/tomcat/bin/
[root@localhost 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.
[root@localhost bin]# 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 :::*
查看进程来查看Tomcat是否真的启动
[root@localhost bin]# ps -ef|grep tomcat
root 52832 1 2 18:17 pts/3 00:00:03 /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 55593 32636 0 18:20 pts/3 00:00:00 grep --color=auto tomcat
3.访问页面
部署多个tomcat
部署多个就是解压压缩包,然后移动到同一个位置进行不同命名,然后修改conf里面server.xml文件里面的端口号即可。
停掉Tomcat
[root@localhost ~]# /usr/local/tomcat/bin/catalina.sh stop
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
[root@localhost ~]# 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 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
[root@localhost ~]# ps -ef|grep tomcat
root 36614 27377 0 18:55 pts/4 00:00:00 grep --color=auto tomcat
删除Tomcat
[root@localhost local]# rm -rf tomcat apache-tomcat-9.0.37/
[root@localhost local]# ls
bin etc games include lib lib64 libexec sbin share src
重新创建Tomcat
[root@localhost local]# mkdir tomcat
[root@localhost local]# cd tomcat/
[root@localhost tomcat]# pwd
/usr/local/tomcat
[root@localhost ~]# ls
! anaconda-ks.cfg apache-tomcat-9.0.37.tar.gz index.jsp
[root@localhost ~]# tar xf a
anaconda-ks.cfg apache-tomcat-9.0.37.tar.gz
[root@localhost ~]# tar xf apache-tomcat-9.0.37.tar.gz
[root@localhost ~]# ls
! anaconda-ks.cfg apache-tomcat-9.0.37 apache-tomcat-9.0.37.tar.gz index.jsp
创建两个新项目qq和weixin
[root@localhost ~]# tar xf apache-tomcat-9.0.37.tar.gz
[root@localhost ~]# mv apache-tomcat-9.0.37 /usr/local/tomcat/qq
[root@localhost ~]# tar xf apache-tomcat-9.0.37.tar.gz
[root@localhost ~]# mv apache-tomcat-9.0.37 /usr/local/tomcat/weixin
[root@localhost ~]# cd /usr/local/
[root@localhost local]# ls
bin etc games include lib lib64 libexec sbin share src tomcat
[root@localhost local]# cd tomcat/
[root@localhost tomcat]# ls
qq weixin
[root@localhost tomcat]# ls
qq weixin
[root@localhost tomcat]# ls qq/
bin conf lib logs README.md RUNNING.txt webapps
BUILDING.txt CONTRIBUTING.md LICENSE NOTICE RELEASE-NOTES temp work
[root@localhost tomcat]# ls weixin/
bin conf lib logs README.md RUNNING.txt webapps
BUILDING.txt CONTRIBUTING.md LICENSE NOTICE RELEASE-NOTES temp work
修改weixin配置,即修改端口号
[root@localhost weixin]# cd conf/
[root@localhost conf]# ls
catalina.policy jaspic-providers.xml server.xml web.xml
catalina.properties jaspic-providers.xsd tomcat-users.xml
context.xml logging.properties tomcat-users.xsd
[root@localhost conf]# vim server.xml
[root@localhost conf]# cat server.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" at this level.
Documentation at /docs/config/server.html
-->
<Server port="8006" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<!-- Security listener. Documentation at /docs/config/listeners.html
<Listener className="org.apache.catalina.security.SecurityListener" />
-->
<!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<!-- Prevent memory leaks due to use of particular java/javax APIs-->
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<!-- Global JNDI resources
Documentation at /docs/jndi-resources-howto.html
-->
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" Note: A "Service" is not itself a "Container",
so you may not define subcomponents such as "Valves" at this level.
Documentation at /docs/config/service.html
-->
<Service name="Catalina">
<!--The connectors can use a shared executor, you can define one or more named thread pools-->
<!--
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="4"/>
-->
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
-->
<Connector port="8081" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8444" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
<!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443
This connector uses the NIO implementation. The default
SSLImplementation will depend on the presence of the APR/native
library and the useOpenSSL attribute of the
AprLifecycleListener.
Either JSSE or OpenSSL style configuration may be used regardless of
the SSLImplementation selected. JSSE style configuration is used below.
-->
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true">
<SSLHostConfig>
<Certificate certificateKeystoreFile="conf/localhost-rsa.jks"
type="RSA" />
</SSLHostConfig>
</Connector>
-->
<!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2
This connector uses the APR/native implementation which always uses
OpenSSL for TLS.
Either JSSE or OpenSSL style configuration may be used. OpenSSL style
configuration is used below.
-->
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol"
maxThreads="150" SSLEnabled="true" >
<UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
<SSLHostConfig>
<Certificate certificateKeyFile="conf/localhost-rsa-key.pem"
certificateFile="conf/localhost-rsa-cert.pem"
certificateChainFile="conf/localhost-rsa-chain.pem"
type="RSA" />
</SSLHostConfig>
</Connector>
-->
<!-- Define an AJP 1.3 Connector on port 8009 -->
<!--
<Connector protocol="AJP/1.3"
address="::1"
port="8009"
redirectPort="8443" />
-->
<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host).
Documentation at /docs/config/engine.html -->
<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
-->
<Engine name="Catalina" defaultHost="localhost">
<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->
<!-- Use the LockOutRealm to prevent attempts to guess user passwords
via a brute-force attack -->
<Realm className="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
</Server>
重启服务,先重启qq 再重启weixin进行对比
[root@localhost ~]# /usr/local/tomcat/qq/bin/catalina.sh start
Using CATALINA_BASE: /usr/local/tomcat/qq
Using CATALINA_HOME: /usr/local/tomcat/qq
Using CATALINA_TMPDIR: /usr/local/tomcat/qq/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/qq/bin/bootstrap.jar:/usr/local/tomcat/qq/bin/tomcat-juli.jar
Tomcat started.
[root@localhost ~]# 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 :::*
[root@localhost ~]# ps -ef|grep tomcat
root 48578 1 6 19:06 pts/4 00:00:02 /usr/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/qq/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/qq/bin/bootstrap.jar:/usr/local/tomcat/qq/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat/qq -Dcatalina.home=/usr/local/tomcat/qq -Djava.io.tmpdir=/usr/local/tomcat/qq/temp org.apache.catalina.startup.Bootstrap start
root 48950 1 12 19:06 pts/4 00:00:02 /usr/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/qq/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/qq/bin/bootstrap.jar:/usr/local/tomcat/qq/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat/qq -Dcatalina.home=/usr/local/tomcat/qq -Djava.io.tmpdir=/usr/local/tomcat/qq/temp org.apache.catalina.startup.Bootstrap start
root 49294 27377 0 19:07 pts/4 00:00:00 grep --color=auto tomcat
对比
[root@localhost ~]# /usr/local/tomcat/weixin/bin/catalina.sh start
Using CATALINA_BASE: /usr/local/tomcat/weixin
Using CATALINA_HOME: /usr/local/tomcat/weixin
Using CATALINA_TMPDIR: /usr/local/tomcat/weixin/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/weixin/bin/bootstrap.jar:/usr/local/tomcat/weixin/bin/tomcat-juli.jar
Tomcat started.
[root@localhost ~]# 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 100 :::8081 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 1 ::ffff:127.0.0.1:8005 :::*
[root@localhost ~]# ps -ef|grep tomcat
root 48578 1 4 19:06 pts/4 00:00:03 /usr/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/qq/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/qq/bin/bootstrap.jar:/usr/local/tomcat/qq/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat/qq -Dcatalina.home=/usr/local/tomcat/qq -Djava.io.tmpdir=/usr/local/tomcat/qq/temp org.apache.catalina.startup.Bootstrap start
root 48950 1 4 19:06 pts/4 00:00:02 /usr/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/qq/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/qq/bin/bootstrap.jar:/usr/local/tomcat/qq/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat/qq -Dcatalina.home=/usr/local/tomcat/qq -Djava.io.tmpdir=/usr/local/tomcat/qq/temp org.apache.catalina.startup.Bootstrap start
root 49847 1 42 19:07 pts/4 00:00:02 /usr/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/weixin/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/weixin/bin/bootstrap.jar:/usr/local/tomcat/weixin/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat/weixin -Dcatalina.home=/usr/local/tomcat/weixin -Djava.io.tmpdir=/usr/local/tomcat/weixin/temp org.apache.catalina.startup.Bootstrap start
root 49976 27377 0 19:07 pts/4 00:00:00 grep --color=auto tomcat
[root@localhost ~]# 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 100 :::8081 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 1 ::ffff:127.0.0.1:8005 :::*
LISTEN 0 1 ::ffff:127.0.0.1:8006 :::*
点击页面
访问拒绝
修改配置文件
[root@localhost conf]# vim tomcat-users.xml
[root@localhost conf]# pwd
/usr/local/tomcat/qq/conf
添加以下内容
重启服务
[root@localhost conf]# ../bin/catalina.sh stop
Using CATALINA_BASE: /usr/local/tomcat/qq
Using CATALINA_HOME: /usr/local/tomcat/qq
Using CATALINA_TMPDIR: /usr/local/tomcat/qq/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/qq/bin/bootstrap.jar:/usr/local/tomcat/qq/bin/tomcat-juli.jar
[root@localhost conf]# 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 :::8081 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 1 ::ffff:127.0.0.1:8006 :::*
[root@localhost conf]# ../bin/catalina.sh start
Using CATALINA_BASE: /usr/local/tomcat/qq
Using CATALINA_HOME: /usr/local/tomcat/qq
Using CATALINA_TMPDIR: /usr/local/tomcat/qq/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/qq/bin/bootstrap.jar:/usr/local/tomcat/qq/bin/tomcat-juli.jar
Tomcat started.
[root@localhost conf]# 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 100 :::8081 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 1 ::ffff:127.0.0.1:8006 :::*
修改另一个文件
[root@localhost qq]# cd webapps/
[root@localhost webapps]# ls
docs examples host-manager manager ROOT
[root@localhost webapps]# cd manager/
[root@localhost manager]# ls
images index.jsp META-INF status.xsd WEB-INF xform.xsl
[root@localhost manager]# cd WEB-INF/
[root@localhost WEB-INF]# ls
jsp web.xml
[root@localhost WEB-INF]# cd ..
[root@localhost manager]# ls
images index.jsp META-INF status.xsd WEB-INF xform.xsl
[root@localhost manager]# cd META-INF/
[root@localhost META-INF]# ls
context.xml
[root@localhost META-INF]# vim context.xml
[root@localhost META-INF]# /usr/local/tomcat/qq/bin/shutdown.sh
Using CATALINA_BASE: /usr/local/tomcat/qq
Using CATALINA_HOME: /usr/local/tomcat/qq
Using CATALINA_TMPDIR: /usr/local/tomcat/qq/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/qq/bin/bootstrap.jar:/usr/local/tomcat/qq/bin/tomcat-juli.jar
[root@localhost META-INF]# 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 :::8081 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 1 ::ffff:127.0.0.1:8006 :::*
[root@localhost META-INF]# /usr/local/tomcat/qq/bin/startup.sh
Using CATALINA_BASE: /usr/local/tomcat/qq
Using CATALINA_HOME: /usr/local/tomcat/qq
Using CATALINA_TMPDIR: /usr/local/tomcat/qq/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/qq/bin/bootstrap.jar:/usr/local/tomcat/qq/bin/tomcat-juli.jar
Tomcat started.
[root@localhost META-INF]# 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 100 :::8081 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 1 ::ffff:127.0.0.1:8006 :::*
[root@localhost META-INF]# 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 100 :::8081 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 1 ::ffff:127.0.0.1:8006 :::*
[root@localhost META-INF]# 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 100 :::8081 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 1 ::ffff:127.0.0.1:8005 :::*
LISTEN 0 1 ::ffff:127.0.0.1:8006 :::*
点击host manager不能访问,修改文件
[root@localhost ~]# cd /usr/local/tomcat/qq/
[root@localhost qq]# ls
bin conf lib logs README.md RUNNING.txt webapps
BUILDING.txt CONTRIBUTING.md LICENSE NOTICE RELEASE-NOTES temp work
[root@localhost qq]# cd webapps/
[root@localhost webapps]# ls
docs examples host-manager manager ROOT
[root@localhost webapps]# cd host-manager/
[root@localhost host-manager]# ls
images index.jsp manager.xml META-INF WEB-INF
[root@localhost host-manager]# cd META-INF/
[root@localhost META-INF]# ls
context.xml
[root@localhost META-INF]# vim context.xml
[root@localhost ~]# cd /usr/local/tomcat/qq/conf/
[root@localhost conf]# ls
Catalina context.xml logging.properties tomcat-users.xsd
catalina.policy jaspic-providers.xml server.xml web.xml
catalina.properties jaspic-providers.xsd tomcat-users.xml
[root@localhost conf]# vim server.xml
[root@localhost conf]# vim tomcat-users.xml
重启服务
[root@localhost conf]# ../bin/shutdown.sh
Using CATALINA_BASE: /usr/local/tomcat/qq
Using CATALINA_HOME: /usr/local/tomcat/qq
Using CATALINA_TMPDIR: /usr/local/tomcat/qq/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/qq/bin/bootstrap.jar:/usr/local/tomcat/qq/bin/tomcat-juli.jar
[root@localhost conf]# 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 :::8081 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 1 ::ffff:127.0.0.1:8006 :::*
[root@localhost conf]# ../bin/startup.sh
Using CATALINA_BASE: /usr/local/tomcat/qq
Using CATALINA_HOME: /usr/local/tomcat/qq
Using CATALINA_TMPDIR: /usr/local/tomcat/qq/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/qq/bin/bootstrap.jar:/usr/local/tomcat/qq/bin/tomcat-juli.jar
Tomcat started.
[root@localhost conf]# 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 100 :::8081 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 1 ::ffff:127.0.0.1:8005 :::*
LISTEN 0 1 ::ffff:127.0.0.1:8006 :::*
[root@localhost conf]# ps -ef|grep tomcat
root 49847 1 0 19:21 ? 00:00:10 /usr/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/weixin/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/weixin/bin/bootstrap.jar:/usr/local/tomcat/weixin/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat/weixin -Dcatalina.home=/usr/local/tomcat/weixin -Djava.io.tmpdir=/usr/local/tomcat/weixin/temp org.apache.catalina.startup.Bootstrap start
root 106051 1 4 20:05 pts/0 00:00:03 /usr/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/qq/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/qq/bin/bootstrap.jar:/usr/local/tomcat/qq/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat/qq -Dcatalina.home=/usr/local/tomcat/qq -Djava.io.tmpdir=/usr/local/tomcat/qq/temp org.apache.catalina.startup.Bootstrap start
root 107396 93895 0 20:07 pts/0 00:00:00 grep --color=auto tomcat
用户名为tomcat 密码为123456,此时密码是之前配置文件修改的
完成以上修改 页面全部都可访问