cenos7 安装tomcat8

安装tomcat需要 先到官网下载tar.gz压缩包

官网入口
我们这里安装的 tomcat 8
下载完后 使用xftp 上传到 /usr/local/src 下

第一步,解压

连接服务器

cd /usr/local/src

到我们放压缩文件的地方 使用

tar -zxvf apache-tomcat-8.5.40.tar.gz

下载的安装包文件不同 记得 修改成自己下载的文件名

压缩完后可以顺手删除掉压缩包

rm -rf apache-tomcat-8.5.40.tar.gz

查看当前文件夹下的文件

[root@VM_0_9_centos src]# ll
 May 15 14:03 tomcat

这里的文件名是我修改后的名字
cd 进入到文件夹里面

[root@VM_0_9_centos tomcat]# ll
May 15 14:03 bin
May  6 06:14 BUILDING.txt
May 15 14:10 conf
May  6 06:14 CONTRIBUTING.md
May 15 14:03 lib
May  6 06:14 LICENSE
May 15 14:10 logs
May  6 06:14 NOTICE
May  6 06:14 README.md
May  6 06:14 RELEASE-NOTES
May  6 06:14 RUNNING.txt
May 15 14:03 temp
May  6 06:12 webapps
May 15 14:10 work

基本上到这一步就安装完成了

启动 需要 进入 bin 目录 然后输入

./startup.sh

就能看到启动信息了

tomcat默认端口号是 8080 如果修改端口号需要返回到tomcat目录下

May 15 14:03 bin
May  6 06:14 BUILDING.txt
May 15 14:10 conf
May  6 06:14 CONTRIBUTING.md
May 15 14:03 lib
May  6 06:14 LICENSE
May 15 14:10 logs
May  6 06:14 NOTICE
May  6 06:14 README.md
May  6 06:14 RELEASE-NOTES
May  6 06:14 RUNNING.txt
May 15 14:03 temp
May  6 06:12 webapps
May 15 14:10 work

我们进入到 conf 文件夹里 并打开配置文件

vim server.xml

看到如下图

[root@VM_0_9_centos conf]# vim 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="8105" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
  <!-- Security listener. Documentation at /docs/config/listeners.html
  <Listener className="org.apache.catalina.security.SecurityListener" />

修改端口号 找到 节点处

        <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    <!-- A "Connector" using the shared thread pool-->

修改 8080 为自己想要的端口

微服务项目还需要检查 每个服务的端口是否和 这里冲突

<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" />

冲突的话 需要修改 8005

至此 服务器上安装tomcat 就完成了
最后启动

./startup.sh

然后去浏览器访问 服务器地址:端口号 就能看到tomcat的欢迎页面了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值