1、检查Linux中的Java环境

[root@localhost ~]# java -version
openjdk version "1.8.0_161"
OpenJDK Runtime Environment (build 1.8.0_161-b14)
OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)
[root@localhost ~]# 

2、解压Tomcat

将桌面上的压缩包,解压到/usr/local

[root@localhost ~]# tar xf /root/Desktop/apache-tomcat-7.0.54.tar.gz -C /usr/local/
[root@localhost ~]# ls
anaconda-ks.cfg  Documents  html                  Music     Public     Videos
Desktop          Downloads  initial-setup-ks.cfg  Pictures  Templates
[root@localhost ~]# cd /usr/local/
[root@localhost local]# ls
apache-tomcat-7.0.54  bin  etc  games  include  lib  lib64  libexec  sbin  share  src
[root@localhost local]# cd apache-tomcat-7.0.54/
[root@localhost apache-tomcat-7.0.54]# ls
bin  conf  lib  LICENSE  logs  NOTICE  RELEASE-NOTES  RUNNING.txt  temp  webapps  work
[root@localhost apache-tomcat-7.0.54]# ls -alh
total 96K
drwxr-xr-x   9 root root  160 Apr  6 19:01 .
drwxr-xr-x. 13 root root  159 Apr  6 19:01 ..
drwxr-xr-x   2 root root 4.0K Apr  6 19:01 bin
drwxr-xr-x   2 root root  158 May 20  2014 conf
drwxr-xr-x   2 root root 4.0K Apr  6 19:01 lib
-rw-r--r--   1 root root  56K May 20  2014 LICENSE
drwxr-xr-x   2 root root    6 May 20  2014 logs
-rw-r--r--   1 root root 1.2K May 20  2014 NOTICE
-rw-r--r--   1 root root 8.8K May 20  2014 RELEASE-NOTES
-rw-r--r--   1 root root  16K May 20  2014 RUNNING.txt
drwxr-xr-x   2 root root   30 Apr  6 19:01 temp
drwxr-xr-x   7 root root   81 May 20  2014 webapps
drwxr-xr-x   2 root root    6 May 20  2014 work
[root@localhost apache-tomcat-7.0.54]# 

3、开启Tomcat服务

[root@localhost bin]# /usr/local/apache-tomcat-7.0.54/bin/startup.sh 

4、通过地址访问

http://172.16.2.100:8080

5、配置管理控制台

  • 开启控制台远程链接

加入这条命令

[root@localhost apache-tomcat-7.0.54]# vim /usr/local/apache-tomcat-7.0.54/webapps/manager/META-INF/context.xml 
[root@localhost apache-tomcat-7.0.54]# cat /usr/local/apache-tomcat-7.0.54/webapps/manager/META-INF/context.xml 

<?xml version="1.0" encoding="UTF-8"?>
<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\.(?:Linked)?HashMap"/>
</Context>

  • 配置远程管理账密
[root@localhost ~]# cd /usr/local/apache-tomcat-7.0.54/
[root@localhost apache-tomcat-7.0.54]# ls
bin  conf  lib  LICENSE  logs  NOTICE  RELEASE-NOTES  RUNNING.txt  temp  webapps  work
[root@localhost apache-tomcat-7.0.54]# cd conf
[root@localhost conf]# ls
Catalina  catalina.policy  catalina.properties  context.xml  logging.properties  server.xml  tomcat-users.xml  web.xml
[root@localhost conf]# vim tomcat-users.xml 
[root@localhost conf]# cat tomcat-users.xml 
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<user username="tomcat" password="tomcat" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/>
</tomcat-users>
[root@localhost conf]# 
  • 重启服务

需要先关闭,然后在启动

[root@localhost conf]# /usr/local/apache-tomcat-7.0.54/bin/shutdown.sh 
Using CATALINA_BASE:   /usr/local/apache-tomcat-7.0.54
Using CATALINA_HOME:   /usr/local/apache-tomcat-7.0.54
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-7.0.54/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/local/apache-tomcat-7.0.54/bin/bootstrap.jar:/usr/local/apache-tomcat-7.0.54/bin/tomcat-juli.jar
[root@localhost conf]# /usr/local/apache-tomcat-7.0.54/bin/startup.sh 
Using CATALINA_BASE:   /usr/local/apache-tomcat-7.0.54
Using CATALINA_HOME:   /usr/local/apache-tomcat-7.0.54
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-7.0.54/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/local/apache-tomcat-7.0.54/bin/bootstrap.jar:/usr/local/apache-tomcat-7.0.54/bin/tomcat-juli.jar
Tomcat started.
[root@localhost conf]# 
  • 成功登录管理控制台

6、主页的分析

 

Logo

更多推荐