在 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>
相關文章
- 在linux環境下安裝JDK並配置環境變數LinuxJDK變數
- webpack(1)安裝環境與解決環境問題Web
- 在linux下安裝並操作tomcatLinuxTomcat
- Tomcat環境JiveJdon原始版安裝問題Tomcat
- 在linux中安裝mysql並解決中文亂碼問題LinuxMySql
- 解決圖片訪問403 Forbidden問題ORB
- 在linux環境下安裝MysqlLinuxMySql
- 在Linux環境下安裝JBOSSLinux
- linux jdk ,tomcat 安裝與環境變數配置LinuxJDKTomcat變數
- 在linux環境安裝單機RocketMQLinuxMQ
- Laravel 在 Docker 環境下訪問 storage 靜態資源 404 問題解決LaravelDocker
- linux安裝java JDK,tomcat,maven等環境變數LinuxJavaJDKTomcatMaven變數
- yapi 在linux環境下的安裝部署APILinux
- 在Linux環境下安裝JDK+JBossLinuxJDK
- Windows 環境安裝 Horizon 報錯解決Windows
- Linux安裝jdk環境LinuxJDK
- Linux環境安裝GOLinuxGo
- Linux環境安裝jdkLinuxJDK
- Linux執行環境安裝全解(轉)Linux
- jdk在linux下安裝、配置環境變數JDKLinux變數
- 在linux,windows上安裝rubyonrails開發環境LinuxWindowsAI開發環境
- 在linux環境下安裝python3.6LinuxPython
- 在Linux環境下安裝Progres資料庫Linux資料庫
- 安裝python虛擬環境並配置虛擬環境以及安裝scrapy模組Python
- Tomcat安裝與環境變數的配置Tomcat變數
- windows安裝tomcat遇到問題及解決方案WindowsTomcat
- 【解除安裝】在LINUX/UNIX環境下解除安裝Oracle的OLAP元件LinuxOracle元件
- mac安裝mysql並配置環境變數MacMySql變數
- 在Linux環境中安裝Qmail的經歷(轉)LinuxAI
- Linux下安裝Go環境LinuxGo
- Linux環境HBase安裝配置Linux
- Linux環境Azkaban安裝配置Linux
- Windows環境下安裝LinuxWindowsLinux
- linux環境下redis安裝LinuxRedis
- Linux環境下安裝NginxLinuxNginx
- LINUX環境下安裝TIPTOPLinux
- hanlp在Python環境中的安裝失敗後的解決方法HanLPPython
- 解決所有環境問題