Du_wood 阅读(93) 评论(0)

主机:腾讯云服务器(ubuntu 16.04.1)系统




  1. 下载所需版本的Tomcat,Tomcat官网:http://tomcat.apache.org/,本文以Tomcat8为例:


  2. 使用FTP工具上传tar.gz包到主机,本文使用xshell配套的xftp:
  3. 使用xshell登录主机,切换至Redis的管理用户,笔者使用的root用户:
    1. ubuntu@VM-202-164-ubuntu:~$ su  
    2. Password:   
    3. root@VM-202-164-ubuntu:/home/ubuntu#   
     说明:如果要使用aaa用户,su - aaa ,再输入密码就好了,或者直接使用aaa登录主机就可以了。
    1. root@VM-202-164-ubuntu:/home/ubuntu# su - aaa   #注意-和aaa之间有一个空格  
  4. 创建Tomcat存放目录,并进入:
    root@VM-202-164-ubuntu:/home/ubuntu# mkdir /usr/servers  
    root@VM-202-164-ubuntu:/home/ubuntu# cd /usr/servers  
  5. 拷贝tomcat包到目录:
    root@VM-202-164-ubuntu:/usr/servers# cp /home/ubuntu/apache-tomcat-8.5.23.tar.gz ./
  6. 解压tar.gz包:
    root@VM-202-164-ubuntu:/usr/servers# tar -xvf apache-tomcat-8.5.23.tar.gz
  7. 删除tomcat自带项目:
    root@VM-202-164-ubuntu:/usr/servers# rm -r apache-tomcat-8.5.23/webapps/*
  8. 给文件夹改个名:
    root@VM-202-164-ubuntu:/usr/servers# mv apache-tomcat-8.5.23 tomcat
  9. 简单配置一下:
    root@VM-202-164-ubuntu:/usr/servers# vi tomcat/conf/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
      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="8005" 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
        <!-- Editable user database that can also be used by
             UserDatabaseRealm to authenticate users
        <Resource name="UserDatabase" auth="Container"
                  description="User database that can be updated and saved"
                  pathname="conf/tomcat-users.xml" />
      <!-- 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
        --><!-- port:可设置tomcat所用端口,URIEncoding:tomcat处理数据所用编码格式,可用于解决操作中文乱码-->
        <Connector port="8080" protocol="HTTP/1.1" URIEncoding="UTF-8"
                   redirectPort="443" /><!-- 此处重定向为SSL所用端口 -->
        <!-- A "Connector" using the shared thread pool-->
        <Connector executor="tomcatThreadPool"
                   port="8080" protocol="HTTP/1.1"
                   redirectPort="8443" />
        <!-- Define a 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
             Either JSSE or OpenSSL style configuration may be used regardless of
             the SSLImplementation selected. JSSE style configuration is used below.
       <!-- port:SSL端口,keystoreFile:指向SSL证书文件,keystorePass:SSL证书密码 -->
        <Connector port="443" protocol="HTTP/1.1" SSLEnabled="true" URIEncoding="UTF-8"
       	 maxThreads="150" scheme="https" secure="true"
       	 clientAuth="false" sslProtocol="TLS" />
        <!-- Define a 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" />
                <Certificate certificateKeyFile="conf/localhost-rsa-key.pem"
                             type="RSA" />
        <!-- Define an AJP 1.3 Connector on port 8009 -->
        <Connector port="8009" protocol="AJP/1.3" 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"
          <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 &quot;%r&quot; %s %b" />
          <!-- <Context docBase="test" path="/test" /></Host> -->
  10. 启动tomcat:
    root@VM-202-164-ubuntu:/home/ubuntu# /usr/servers/tomcat/bin/startup.sh
    root@VM-202-164-ubuntu:/home/ubuntu# ps -aux|grep tomcat|grep -v grep
     说明:ps -aux|grep tomcat|grep -v grep命令可查看已经启动的tomcat进程,如下:
    root@VM-202-164-ubuntu:/usr/servers/tomcat8-server1/bin# ps -aux|grep tomcat|grep -v grep
    root     32087  7.5  6.0 2129240 53780 pts/1   Sl   23:26   0:01 /usr/servers/jdk1.8.0_151//bin/java -Djava.util.logging.config.file=/usr/servers/tomcat8-server1/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -classpath /usr/servers/tomcat8-server1/bin/bootstrap.jar:/usr/servers/tomcat8-server1/bin/tomcat-juli.jar -Dcatalina.base=/usr/servers/tomcat8-server1 -Dcatalina.home=/usr/servers/tomcat8-server1 -Djava.io.tmpdir=/usr/servers/tomcat8-server1/temp org.apache.catalina.startup.Bootstrap start
  11. 停止tomcat:
    root@VM-202-164-ubuntu:/home/ubuntu# /usr/servers/tomcat/bin/shutdown.sh
    root@VM-202-164-ubuntu:/home/ubuntu# ps -aux|grep tomcat|grep -v grep
  12. 最后删掉tar.gz包,这个文件已经解压过了,留之无用,删了就好。
    root@VM-202-164-ubuntu:~# rm /usr/servers/apache-tomcat-8.5.23.tar.gz



  • 大小: 47.2 KB
  • 大小: 40.7 KB
  • 大小: 103 KB