yum安装tomcat

yum安装tomcat

http://www.cnblogs.com/liaolongjun/p/5638740.html

http://www.awspack.com/os/linux/yum-install-tomcat/

在服务器跑Java程序的时候,经常用的Web服务器就是Tomcat,今天用yum命令试着安装了一下。

编译安装的时候需要安装JDKTomcat,而yum安装Tomcat直接把OpenJDK也给安装上了。

yum安装Tomcat
先查看一下yum安装时的Tomcat版本

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

# yum info tomcat

Loaded plugins: security

Available Packages

Name        : tomcat

Arch        : noarch

Version     : 7.0.33

Release     : 4.el6

Size        : 86 k

Repo        : epel

Summary     : Apache Servlet/JSP Engine, RI for Servlet 3.0/JSP 2.2 API

URL         : http://tomcat.apache.org/

License     : ASL 2.0

Description : Tomcat is the servlet container that is used in the official Reference

            : Implementation for the Java Servlet and JavaServer Pages technologies.

            : The Java Servlet and JavaServer Pages specifications are developed by

            : Sun under the Java Community Process.

            :

            : Tomcat is developed in an open and participatory environment and

            : released under the Apache Software License version 2.0. Tomcat is intended

            : to be a collaboration of the best-of-breed developers from around the world.

Tomcat最新版本是2015/11/24发布的Tomcat8.0.29,而yum安装版本是2012/11/21发布的7.0.33(版本确实低了)

安装Tomcat

yum -yinstall tomcat  tomcat-webappstomcat-admin-webapps tomcat-docs-webapp tomcat-javadoc

安装Tomcat之后查看安装的版本。

 

[root@node121 bin]# tomcatversion

Server version: Apache Tomcat/7.0.75

Server built:   Feb 17 2017 20:18:45 UTC

Server number:  7.0.75.0

OS Name:        Linux

OS Version:     2.6.32-573.el6.x86_64

Architecture:   amd64

JVM Version:    1.6.0_35-b35

JVM Vendor:     Sun Microsystems Inc.

 

安装Tomcat时直接把OpenJDK也安装了

在这里可以看到安装的JDK不是OracleJDK而是OpenJDK

 

 

1

2

3

4

# java -version

openjdk version "1.8.0_65"

OpenJDK Runtime Environment (build 1.8.0_65-b17)

OpenJDK 64-Bit Server VM (build 25.65-b01, mixed mode)

 

可以使用alternatives切换使用的Java版本。 

 

1

2

3

4

5

6

7

8

# alternatives --config java

 

There are 2 programs which provide 'java'.

 

  Selection    Command

-----------------------------------------------

   1           /usr/lib/jvm/jre-1.5.0-gcj/bin/java

*+ 2           /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java

 

yum安装后的tomcat目录说明:

配置文件目录:/etc/tomcat

安装程序主目录:/var/lib/tomcat/

Centos使用yum安装后,Tomcat相关的目录都已采用符号链接到/usr/share/tomcat目录,包含webapps等,这很方便我们配置管理

[root@tomcattest tomcat6]# ll /usr/share/tomcat

drwxr-xr-x. 2 root root   4096 10 1900:44 bin

lrwxrwxrwx. 1 root tomcat   12 10 1900:44 conf ->/etc/tomcat6

lrwxrwxrwx. 1 root root     23 10 1900:44 lib ->/usr/share/java/tomcat6

lrwxrwxrwx. 1 root root     16 10 1900:44 logs ->/var/log/tomcat6

lrwxrwxrwx. 1 root root     23 10 1900:44 temp ->/var/cache/tomcat6/temp

lrwxrwxrwx. 1 root root     24 10 1900:44 webapps ->/var/lib/tomcat6/webapps

lrwxrwxrwx. 1 root root     23 10 1900:44 work ->/var/cache/tomcat6/work

 

修改端口808080

80端口未被占用可以使用netstat-nat查看80端口是否在使用。

a)修改vi /etc/tomcat/server.xml文件的如下字段中的808080

<Connector port="8080"protocol="HTTP/1.1"

             connectionTimeout="20000"

             redirectPort="8443" />

b)由于在Centos6系统不允许tomcat用户使用1024以下的端口因此还需修改vi /etc/tomcat6/tomcat6.conf

找到CONNECTOR_PORT="8080"并注释掉新增如下两行

TOMCAT_USER="root"

CONNECTOR_PORT="80"

这样做的安全性有待验证

c)检查防火墙状态 /etc/init.d/iptablesstatus

 关闭防火墙      /etc/init.d/iptables stop

d使用命令service tomcat6 restart 重启tomcat服务。以后访问页面就可以只需要输入IP或者主机名即可,而不再需要加端口号。

这大概就是安装配置tomcat的基本过程了,当然在访问的过程也会遇到问题,比如,localhost(端口)访问页面显示空白;或者本地能访问其他客服端不能访问tomcat等,有时间再讨论遇到的问题!

 

 

使用Tomcat管理页面

访问Tomcat管理页面(http://localhost:8080/manager/html)需要安装tomcat-admin-webapps和修改tomcat-users.xml文件。

 

安装tomcat-admin-webapps

 

1

# yum install tomcat-admin-webapps

修改tomcat-users.xml文件

修改tomcat-users.xml文件(默认安装目录是/etc/tomcat)添加46-48行的内容。

/etc/tomcat/tomcat-users.xml

 

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

<?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>

<!--

  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.

-->

<!--

  NOTE:  The sample user and role entries below are wrapped in a comment

  and thus are ignored when reading this file. Do not forget to remove

  <!....> that surrounds them.

-->

<!--

  <role rolename="tomcat"/>

  <role rolename="role1"/>

  <user username="tomcat" password="tomcat" roles="tomcat"/>

  <user username="both" password="tomcat" roles="tomcat,role1"/>

  <user username="role1" password="tomcat" roles="role1"/>

-->

 

<!-- <role rolename="admin"/> -->

<!-- <role rolename="admin-gui"/> -->

<!-- <role rolename="admin-script"/> -->

<!-- <role rolename="manager"/> -->

<!-- <role rolename="manager-gui"/> -->

<!-- <role rolename="manager-script"/> -->

<!-- <role rolename="manager-jmx"/> -->

<!-- <role rolename="manager-status"/> -->

<!-- <user name="admin" password="adminadmin" roles="admin,manager,admin-gui,admin-script,manager-gui,manager-script,manager-jmx,manager-status" /> -->

<role rolename="admin-gui"/>

<role rolename="manager-gui"/>

<user username="tomcat" password="tomcat" roles="admin-gui,manager-gui"/>

</tomcat-users>

访问Tomcat管理页面

访问http://localhost:8080/manager/html并输入48行里设定的usernamepassword就可以了。

 

 

JVM内存池

JVM

Free memory: 13.80 MB Total memory:24.61 MB Max memory: 235.87 MB

Memory Pool    Type Initial         Total Maximum Used

Eden Space       Heap memory   2.00 MB    6.87 MB    65.06MB 1.15 MB (1%)

Survivor Space Heap memory   0.25MB    0.81 MB    8.12 MB    0.00 MB (0%)

Tenured Gen     Heap memory   5.12 MB    16.92 MB 162.68MB        9.65 MB (5%)

Code Cache       Non-heap memory    2.43MB    2.43 MB    48.00 MB 1.76 MB (3%)

Perm Gen Non-heap memory    20.75 MB 22.81 MB 166.00MB        22.51 MB (13%)

Eden:伊甸园区(新的进程)

Survivor 存活区

Tenured 老年区

Code       代码缓存区

 


 

Manager app: webapp管理工具

host manager:      virtualhosts 管理工具

 

 

分割线
感谢打赏
江西数库信息技术有限公司
YWSOS.COM 平台代运维解决方案
 评论
 发表评论
姓   名:

Powered by AKCMS