Centos7 下安装配置tomcat7
首先下載壓縮包
wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-7/v7.0.78/bin/apache-tomcat-7.0.78.zip
如果centos7是最小版安裝的話,還需要安裝配置java環境
可參考http://www.cnblogs.com/biaopei/p/7730484.html
解壓
unzip apache-tomcat-7.0.78.zip
需要給該目錄下的三個文件執行權限chmod 755
這三個文件你分別是catalina.sh shutdown.sh startup.sh
開啟tomcat需要執行./startup.sh
關閉tomcat需要執行./shudown.sh
瀏覽器打開localhost:8080進行訪問
啥,不能訪問,喜歡簡單粗暴的就直接關閉防火墻,紳士一點就讓防火墻通過8080端口吧,即執行以下命令
iptables -I INPUT -p tcp –dport=8080 -j ACCEPT
給個成功效果圖
?
不出意外的話,tomcat雖然可以正常訪問,但是,我們無法進入圖形化管理后臺,這個還需要另外配置
[root@localhost ~]# cd apache-tomcat-9.0.2/conf/
[root@localhost conf]# ls
Catalina catalina.policy catalina.properties context.xml jaspic-providers.xml jaspic-providers.xsd logging.properties server.xml tomcat-users.xml tomcat-users.xsd web.xml
配置tomcat-users.xml文件,在該文件末尾增加以下內容
<role rolename="manager-gui"/>
<user username="tomcat" password="123456" roles="manager-gui"/>
?
除此之外還需要配置
[root@localhost META-INF]# pwd
/root/apache-tomcat-9.0.2/webapps/manager/META-INF
[root@localhost META-INF]# ls
context.xml
[root@localhost META-INF]# cat 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.
# allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
-->
<Context antiResourceLocking="false" privileged="true" >
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="^.*$" /> ? ? ?修改這里
<Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linke
d)?HashMap"/></Context>
[root@localhost META-INF]#
最后重啟,就可以進入tomcat的server status了,用戶名為tomcat,密碼123456
?tomcat網站目錄位于apache-tomcat-9.0.2/webapps/ROOT目錄下
轉載于:https://www.cnblogs.com/biaopei/p/7730587.html
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的Centos7 下安装配置tomcat7的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ICO取缔一锤定音,投资者、发起方、交易
- 下一篇: 1.文件I/O