主机:腾讯云服务器(ubuntu 16.04.1)系统
工具:xshell
步骤↓:
- 下载所需版本的Tomcat,Tomcat官网:http://tomcat.apache.org/,本文以Tomcat8为例:
下载所选版本Tomcat中,core中的tar.gz包。
- 使用FTP工具上传tar.gz包到主机,本文使用xshell配套的xftp:
- 使用xshell登录主机,切换至Redis的管理用户,笔者使用的root用户:
- ubuntu@VM-202-164-ubuntu:~$ su
- Password:
- root@VM-202-164-ubuntu:/home/ubuntu#
- root@VM-202-164-ubuntu:/home/ubuntu# su - aaa #注意-和aaa之间有一个空格
- 创建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中,依个人习惯而定。 -
拷贝tomcat包到目录:
root@VM-202-164-ubuntu:/usr/servers# cp /home/ubuntu/apache-tomcat-8.5.23.tar.gz ./
-
解压tar.gz包:
root@VM-202-164-ubuntu:/usr/servers# tar -xvf apache-tomcat-8.5.23.tar.gz
-
删除tomcat自带项目:
root@VM-202-164-ubuntu:/usr/servers# rm -r apache-tomcat-8.5.23/webapps/*
-
给文件夹改个名:
root@VM-202-164-ubuntu:/usr/servers# mv apache-tomcat-8.5.23 tomcat
- 简单配置一下:
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 "%r" %s %b" /> </Host> <!-- <Context docBase="test" path="/test" /></Host> --> <!--部署web项目的一种方法:1、直接将项目丢进webapps目录中,2、用此配置,path指向项目根目录--> </Engine> </Service> </Server>
- 启动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
- 停止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进程。 -
最后删掉tar.gz包,这个文件已经解压过了,留之无用,删了就好。
root@VM-202-164-ubuntu:~# rm /usr/servers/apache-tomcat-8.5.23.tar.gz
搞定!
相关推荐
ubuntu16.04.1操作系统下 mysql安装和卸载图文教程说明
ubuntu 下安装配置tomcat,亲自实践总结的文档,ubuntu版本:ubuntu-10.10-amd64
ubuntu mysql apache2 tomcat 安装配置
ubuntu linux下安装tomcat
ubuntu8.04中配置java+tomcat+eclipseMyEclipse开发环境(更新)
ubuntu 16.04安装tomcat 8.0图文详细教程
Ubuntu 12.04 安装配置 Tomcat 7.0.40Tomcat 服务器.docx
ubuntu8.04速成手册1.0.rar ubuntu8.04 ubuntu8安装与配置 ubuntu8.0.4实用手册
windows7上VMware虚拟机上三台ubuntu10.10上hadoop的安装及配置详解
ubuntu16.04 server版本的镜像,可以用来做u盘启动盘等等,此版感觉还可以,本人因为要经常搭建服务器,基本linux用的都是此镜像,多次实践,没有什么大毛病,bug。
1买服务器 云服务器购买 ...远端OS是Ubuntu 18.04,服务器在日本 注释掉 5写一个html网页,重命名为index.html,在apache-tomcat-8.5.51/webapp中,新建一个文件夹,名字随意,把网页拖到里面 6
Ubuntu22.04安装教程以及Ubuntu下C++环境配置
ubuntu网络配置ubuntu网络配置ubuntu网络配置
ubuntu linux 下apache与tomcat的整合.txt
在ubuntu系统中安装jdk、tomcat. 在ubuntu系统中安装jdk、tomcat. 在ubuntu系统中安装jdk、tomcat.
详解Ubuntu Linux的安装与配置过程,对于新手是很有用的哦……
ubuntu 23.04 QEMU图形化安装配置网卡桥接
ubuntu上安装与配置samba服务
Ubuntu Kylin 14.04 安装配置 jdk、eclipse、tomcat 通用,对于环境配置做出详细的说明