Tomcat 部署:

准备部署tomcat前的一些准备工作:

  groupadd tomcat -g1002

 

useradd tomcat-u 1002 -g 1002

 

passwd   tomcat

tomcat123!@#

 

 

       [root@rabbitmq_slave tomcat_software]#pwd

/usr/local/src/tomcat_software

 

[root@rabbitmq_slavetomcat_software]# ll

total 96416

-rw-r--r-- 1 rootroot  8234674 May 16 08:59apache-tomcat-7.0.47.tar.gz

-rw-r--r-- 1 rootroot  1016391 May 16 09:08apr-1.5.0.tar.gz

-rw-r--r-- 1 rootroot   874462 May 16 09:08apr-util-1.5.3.tar.gz

-rw-r--r-- 1 rootroot  2934099 May 16 09:00 apr.zip

-rw-r--r-- 1 rootroot 85414670 May 16 09:08 jdk-7u25-linux-x64.rpm

-rw-r--r-- 1 rootroot   241274 May 16 09:14tomcat-native-1.1.20-src.tar.gz

 

 

在安装Tomcat之前需要安装j2sdk(Java 2Software Development Kit),也就是JDK

接下来开始安装JDK并设置环境变量:

      [root@rabbitmq_slave tomcat_software]# rpm -ivh jdk-7u25-linux-x64.rpm

       [root@rabbitmq_slave tomcat_software]# ln -s /usr/java/jdk1.7.0_25 /usr/local/jdk

vi /etc/profile #在他文件末尾处添加下面的变量:

      # java

JAVA_HOME=/usr/local/jdk

PATH=$JAVA_HOME/bin:$PATH

CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export JAVA_HOME

export PATH

export CLASSPATH

[root@rabbitmq_slave tomcat_software]# source/etc/profile

查看jdk是否安装成功,执行以下命令:

       [root@rabbitmq_slave~]# java -version

java version "1.7.0_25"

Java(TM) SE Runtime Environment (build 1.7.0_25-b15)

Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixedmode)

如果控制台输出jdk的版本类似如上1.7.0_25,则表明安装成功。

 

安装tomcat

    [root@rabbitmq_slave tomcat_software]# pwd

/usr/local/src/tomcat_software

[root@rabbitmq_slave tomcat_software]# tar zxfapache-tomcat-7.0.47.tar.gz -C /usr/

[root@rabbitmq_slave tomcat_software]# cd  /usr/

[root@rabbitmq_slave usr]#  mv apache-tomcat-7.0.47 /usr/local/tomcat7

[root@rabbitmq_slave usr]# cd /usr/local/tomcat7/conf

[root@rabbitmq_slave conf]# pwd

/usr/local/tomcat7/conf

[root@rabbitmq_slave conf]# cat tomcat-users.xml

<?xml version='1.0' encoding='utf-8'?>

<!--

  Licensed tothe Apache Software Foundation (ASF) under one or more

  contributorlicense agreements.  See the NOTICE filedistributed with

  this work foradditional information regarding copyright ownership.

  The ASFlicenses this file to You under the Apache License, Version 2.0

  (the"License"); you may not use this file except in compliance with

  theLicense.  You may obtain a copy of theLicense at

 

     http://www.apache.org/licenses/LICENSE-2.0

 

  Unlessrequired by applicable law or agreed to in writing, software

  distributedunder the License is distributed on an "AS IS" BASIS,

  WITHOUTWARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  See theLicense for the specific language governing permissions and

  limitationsunder 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 mustdefine such a user - the username and password are arbitrary.

-->

<!--

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

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

  <!.. ..>that surrounds them.

-->

<!--

  <rolerolename="tomcat"/>

  <rolerolename="role1"/>

  <userusername="tomcat" password="tomcat"roles="tomcat"/>

  <userusername="both" password="tomcat"roles="tomcat,role1"/>

  <userusername="role1" password="tomcat"roles="role1"/>

-->

<rolerolename="admin"/>

<rolerolename="manager-gui"/>

<userusername="admin" password="123456" roles="admin,manager-gui,manager"/>

</tomcat-users>

[root@rabbitmq_slave conf]# cd /usr/local/tomcat7/bin/

chowntomcat:tomcat  /usr/local/tomcat7/  -R

[root@rabbitmq_slavebin]# su – tomcat

[tomcat@rabbitmq_slave~]$ cd /usr/local/tomcat7/bin

 

 

使用tomcat用户启动tomcat后台执行:

[tomcat@rabbitmq_slave bin]$ nohup &

       启动后,网页测试,在浏览器中输入http://ip:8080。看能否显示tomcat界面,admin用户登录试试。

 

 

注:家目录:/data/tomcat