在 Linux 安裝 tomcat 環境,並解決訪問manager 403
全文共兩部分,安裝tomcat和配置tomcat。
安裝tomcat
1.首先安裝好jdk
yum install java-1.8.0-openjdk.x86_64 --安裝jdk1.8
java -version --檢查jdk是否安裝好
2.在官網下載apache-tomcat-7.0.107.tar.gz,並用ftp上傳到伺服器,並解壓。解壓好了即使安裝好了。
tar -xvf apache-tomcat-7.0.107.tar.gz
3.驗證是否安裝成功A。切換到apache-tomcat-7.0.107/bin目錄下,sh startup.sh
,成功啟動,如下圖。
4.驗證是否安裝成功B。windows開啟瀏覽器,輸入http://伺服器IP:8080/,成功開啟tomcat主頁,如下圖,說明安裝成功。
配置tomcat
此時,如果我們訪問Server Status,會報錯403。這需要我們完成以下兩步配置:
1.修改配置檔案apache-tomcat-7.0.107/conf/tomcat-users.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.
-->
<tomcat-users xmlns="http://tomcat.apache.org/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
version="1.0">
<!--
NOTE: By default, no user is included in the "manager-gui" role required
to operate the "/manager/html" web application. If you wish to use this app,
you must define such a user - the username and password are arbitrary. It is
strongly recommended that you do NOT use one of the users in the commented out
section below since they are intended for use with the examples web
application.
-->
<!--
NOTE: The sample user and role entries below are intended for use with the
examples web application. They are wrapped in a comment and thus are ignored
when reading this file. If you wish to configure these users for use with the
examples web application, do not forget to remove the <!.. ..> that surrounds
them. You will also need to set the passwords to something appropriate.
-->
<role rolename="tomcat"/>
<role rolename="manager"/>
<role rolename="manager-gui"/>
<role rolename="manager-script" />
<role rolename="admin-gui"/>
<user username="tomcat" password="tomcat" roles="tomcat,manager,manager-gui,manager-script,admin-gui" />
</tomcat-users>
2.配置好了tomcat-users.xml,我們此時再訪問Server Status
仍然會報錯404,因為apache-tomcat-8.5.59\webapps\manager\META-INF\context.xml配置檔案限制了訪問ip,預設只能環回地址才能訪問,而我們是通過ip遠端訪問,故我們修改這個配置檔案。只需要修改allow
後面的內容,配置檔案全文如下:
<?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="\d+\.\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>
相關文章
- webpack(1)安裝環境與解決環境問題Web
- 解決圖片訪問403 Forbidden問題ORB
- 在linux環境安裝單機RocketMQLinuxMQ
- yapi 在linux環境下的安裝部署APILinux
- Linux安裝jdk環境LinuxJDK
- Linux環境安裝GOLinuxGo
- Laravel 在 Docker 環境下訪問 storage 靜態資源 404 問題解決LaravelDocker
- jdk在linux下安裝、配置環境變數JDKLinux變數
- 在linux,windows上安裝rubyonrails開發環境LinuxWindowsAI開發環境
- PbootCMS 織夢安裝出現403錯誤禁止訪問boot
- Windows 環境安裝 Horizon 報錯解決Windows
- Linux系統安裝tomcat並部署專案。LinuxTomcat
- linux環境安裝——mysql安裝複習LinuxMySql
- linux環境安裝——kafka安裝複習LinuxKafka
- Linux下Java環境安裝LinuxJava
- Linux環境下安裝NginxLinuxNginx
- Linux下安裝Go環境LinuxGo
- Linux環境HBase安裝配置Linux
- Linux環境Azkaban安裝配置Linux
- linux環境下redis安裝LinuxRedis
- Windows環境下安裝LinuxWindowsLinux
- Tomcat7安裝基於jdk 1.7環境TomcatJDK
- 使用docker搭建環境:安裝tomcat、部署war包DockerTomcat
- linux安裝tomcatLinuxTomcat
- linux或者CentOS環境下安裝.NET Core環境LinuxCentOS
- hanlp在Python環境中的安裝失敗後的解決方法HanLPPython
- 安裝python虛擬環境並配置虛擬環境以及安裝scrapy模組Python
- DB2 Linux環境安裝DB2Linux
- Linux系統安裝ansiblle環境Linux
- linux環境安裝——整理彙總Linux
- Linux環境下nginx安裝配置LinuxNginx
- Linux環境下ApacheActiveMQ基本安裝LinuxApacheMQ
- 簡單安裝PHP在Linux下的執行環境PHPLinux
- Linux配置JavaEE環境 Linux中安裝JDK、Tomcat、mysql 設定Tomcat自啟動、設定mysql自啟動LinuxJavaJDKTomcatMySql
- 快速搭建 Linux(LNMP + Linux 安裝 + 環境配置)LinuxLNMP
- 在Ubuntu環境下安裝eclipseUbuntuEclipse
- mac安裝mysql並配置環境變數MacMySql變數
- 解決所有環境問題