云服务器Tomcat配置

1.下载FileZilla

这里提一下关于FileZilla的登录方法

  • 主机(H):此处填写你购买的云服务器的外网IP地址
  • 用户名(U):此处填写root
  • 密码(W):此处填写root的登录密码,就是你在安装系统时设置的密码
  • 端口(P):此处统一填写22

2.下载Tomcat

请自行到Tomcat官网下载apache-tomcat-8.5.9

3.使用FileZilla将Tomcat上传到服务器

将下载的apache-tomcat-8.5.16.tar.gz文件上传到云服务器的/usr/soft/temp文件夹下

开始配置Tomcat服务器

  • 解压apache-tomcat-8.5.16.tar.gz文件至/usr/soft/tomcat文件夹下,如果没有tomcat文件夹需要自己手动创建。
tar zxvf apache-tomcat-8.5.16.tar.gz -C /usr/soft/tomcat
  • 设置JDK
cd /usr/tomcat/apache-tomcat-8.5.16/bin
vi setclasspath.sh

按'i'键后进行编辑;按'esc'键退出编辑模式后再按':'键然后输入'wq'回车进行保存;

在末尾添加以下设置:

# Set Java Environment
export JAVA_HOME=/usr/java/jdk/jdk1.7.0_80
export JRE_HOME=/usr/java/jdk/jdk1.7.0_80/jre
  • 配置Tomcat服务器
  1. 添加用户
    在<tomcat>/conf/tomcat-users.xml中添加以下用户
  <role rolename="admin"/>
  <role rolename="manager"/>
  <role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <user username="admin" password="admin" roles="admin,manager,manager-gui,manager-script"/>

2.配置tomcat管理器可以远程访问的权限
tomcat默认不支持远程访问管理器,默认只能在同一台机器上访问manager,所以如果想在云服务器上访问manager需要解除该限制。
打开<tomcat>/webapps/manager/META-INF/context.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.
-->
<Context antiResourceLocking="false" privileged="true" >
  <!-- <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> -->
  <Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
</Context>

注释掉

<Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />

即可。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容