`

ubuntu 16.04.1 上tomcat的安装与配置

阅读更多

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

工具:xshell

 

步骤↓:

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

     

     
    下载所选版本Tomcat中,core中的tar.gz包。
     
  2. 使用FTP工具上传tar.gz包到主机,本文使用xshell配套的xftp:
  3. 使用xshell登录主机,切换至Redis的管理用户,笔者使用的root用户:
    Shell代码 
    1. ubuntu@VM-202-164-ubuntu:~$ su  
    2. Password:   
    3. root@VM-202-164-ubuntu:/home/ubuntu#   
     说明:如果要使用aaa用户,su - aaa ,再输入密码就好了,或者直接使用aaa登录主机就可以了。
    Shell代码 
    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  
    root@VM-202-164-ubuntu:/usr/servers# 
     注:笔者将Tomcat放在usr/severs中,依个人习惯而定。
  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
    
          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="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
      -->
      <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
        --><!-- port:可设置tomcat所用端口,URIEncoding:tomcat处理数据所用编码格式,可用于解决操作中文乱码-->
        <Connector port="8080" protocol="HTTP/1.1" URIEncoding="UTF-8"
                   connectionTimeout="20000"
                   redirectPort="443" /><!-- 此处重定向为SSL所用端口 -->
        <!-- A "Connector" using the shared thread pool-->
        <!--
        <Connector executor="tomcatThreadPool"
                   port="8080" protocol="HTTP/1.1"
                   connectionTimeout="20000"
                   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
             AprLifecycleListener.
             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"
       	 keystoreFile="conf/aaa.jks"
       	 keystorePass="123456"
       	 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" />
            <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 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"
                   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 &quot;%r&quot; %s %b" />
    
          </Host>      
          <!-- <Context docBase="test" path="/test" /></Host> -->
          <!--部署web项目的一种方法:1、直接将项目丢进webapps目录中,2、用此配置,path指向项目根目录-->
    
        </Engine>
      </Service>
    </Server>
    
     
  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
     说明:执行关闭脚本,看看是否还有tomcat进程。
  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
1
0
分享到:
评论

相关推荐

    ubuntu16.04.1下 mysql安装和卸载图文教程

    Ubuntu是一种广泛使用的开源操作系统,基于Linux内核,适用于服务器和个人计算机。MySQL是一个流行的开源关系型数据库管理系统,广泛应用于各种...通过上述步骤,用户可以在Ubuntu系统上成功安装和管理MySQL数据库。

    ubuntu 下安装配置tomcat

    ### Ubuntu下安装配置Tomcat #### 一、前言与环境准备 在Ubuntu系统中部署Java Web应用时,经常需要用到Apache Tomcat服务器。本文将详细介绍如何在Ubuntu 10.10-amd64版系统上安装并配置Tomcat。通过本教程,你将...

    ubuntu下安装tomcat

    在Ubuntu系统上运行Tomcat前,首先需要确保已经安装了Java Development Kit (JDK)。这是因为Tomcat是用Java编写的,因此依赖于JDK来运行。以下是在Ubuntu系统中安装Sun JDK的步骤: 1. **更新包列表**:首先,使用`...

    ubuntu8.04中配置java+tomcat+eclipseMyEclipse开发环境(更新)

    本文将深入解析如何在Ubuntu 8.04系统上搭建这套开发环境,涵盖Java环境的配置、Tomcat服务器的安装与启动、以及集成开发环境Eclipse MyEclipse的设置。 ### Java环境配置 #### 安装Java运行环境与开发工具包(JDK)...

    ubuntu mysql apache2 tomcat 安装配置

    ubuntu mysql apache2 tomcat 安装配置

    Tomcat的安装及配置教程步骤

    本教程将详细介绍在Windows、Linux和macOS操作系统上安装与配置Tomcat的步骤。 1. **Windows上的安装** - 下载:首先,访问Apache Tomcat官方网站下载最新版本的Tomcat安装包,通常是.zip格式。 - 解压:下载完成...

    Ubuntu下使用Tomcat搭建网站出现中文乱码的问题.docx

    要解决 Ubuntu 下使用 Tomcat 搭建网站出现中文乱码的问题,需要统一服务器的字符编码,包括 Linux 服务器、Tomcat 配置文件和 MySQL 数据库。通过统一字符编码,可以确保服务器的字符编码是一致的,避免乱码的出现...

    Ubuntu 12.04 安装配置 Tomcat 7.0.40Tomcat 服务器.docx

    在本文档中,我们详细介绍了如何在Ubuntu 12.04系统上安装和配置Tomcat 7.0.40服务器。以下是整个过程的详细步骤: 1. 首先,由于Ubuntu官方源中的Tomcat版本可能不是最新的,因此我们需要从Apache官方网站下载...

    ubuntu配置多个tomcat方法

    1. **安装Java环境**:确保服务器上已经安装了Java运行环境(JRE)或Java开发工具包(JDK),因为Tomcat依赖于Java环境才能正常运行。 ```bash sudo apt-get update sudo apt-get install default-jdk ``` 2....

    Ubuntu Kylin 14.04 安装配置 jdk、eclipse、tomcat 通用

    Ubuntu Kylin 14.04 安装配置 jdk、eclipse、tomcat 通用 一、安装 jdk 安装 jdk 是 Ubuntu Kylin 14.04 操作系统中配置 java 开发环境的第一步骤。我们可以从 Oracle 官网下载 jdk,网址为 ...

    Ubuntu22.04安装教程以及Ubuntu下C++环境配置

    "Ubuntu22.04安装教程以及Ubuntu下C++环境配置" 本教程旨在指导读者如何安装 Ubuntu 22.04 操作系统,并配置 C++ 编程环境。下面将详细介绍安装和配置过程中的每一步骤。 一、安装 VMware 在开始安装 Ubuntu 之前...

    linux下Nginx+tomcat整合的安装与配置

    ### Linux下Nginx+Tomcat整合的安装与配置详解 在现代的Web服务器架构中,Nginx作为高性能的反向代理服务器和负载均衡器,常被用来与Tomcat等应用服务器配合使用,以提高网站的响应速度、稳定性和安全性。本文将...

    ubuntu18.04 + Tomcat安装及配置

    1买服务器 云服务器购买 ...远端OS是Ubuntu 18.04,服务器在日本 注释掉 5写一个html网页,重命名为index.html,在apache-tomcat-8.5.51/webapp中,新建一个文件夹,名字随意,把网页拖到里面 6

    Ubuntu10.10Tomcat、MySQL的配置.pdf

    本资源主要介绍了在 Ubuntu 10.10 操作系统上安装和配置 Tomcat 和 MySQL 的步骤,以及相关的知识点。 Java JDK 安装 Java JDK 是 Tomcat 和 MySQL 的依赖项之一,因此需要首先安装 Java JDK。在 Ubuntu 10.10 上...

    ubuntu linux下apache与tomcat的整合.txt

    接下来,我们将详细介绍如何在 Ubuntu Linux 系统中安装配置 Apache 与 Tomcat 的整合。 #### 安装 mod_jk 模块 1. **下载并解压** `tomcat-connectors-1.2.15-src.tar.gz` 文件: ```bash tar -zxvf tomcat-...

    ubuntu8.04速成手册1.0.rar ubuntu8.04 ubuntu8安装与配置

    《Ubuntu 8.04速成手册1.0》是一份专为初学者设计的指南,旨在帮助用户快速掌握Ubuntu 8.04的操作系统安装、配置和日常使用技巧。Ubuntu 8.04,代号“Hardy Heron”,是Ubuntu Linux发行版的一个重要版本,发布于...

    Ubuntu上Tomcat部署war包失败的解决办法.docx

    本文将详细介绍 Ubuntu 上 Tomcat 部署 war 包失败的解决办法,涵盖了 jdk 版本不对、war 包中的库与 Tomcat 自带的库矛盾、Tomcat 初始页中的推举工具、日志文件的重要性等方面。 一、jdk 版本不对 在 Ubuntu 上...

Global site tag (gtag.js) - Google Analytics