操作系统: CentOS 6,5
目标主机:172.16.10.122 172.10.10.133
第一步:安装Java虚拟机
可以根据自己的需要下载。下载地址是:
chmod
+x jdk-6u31-linux-x64-rpm.bin
.
/jdk-6u31-linux-x64-rpm
.bin
export
JAVA_HOME=
/usr/java/latest
export
PATH=
/usr/java/latest/bin/
:$PATH
source
/etc/profile
.d
/java
.sh
第二步:安装tomcat
tar
xf ache-tomcat-7.0.55.
tar
.gz -C
/usr/local
ln
-sv apache-tomcat-7.0.55 tomcat
export
CATALINA_HOME=
/usr/local/tomcat
export
PATH=$CATALINA_HOME
/bin
:$PATH
第三步:添加测试站点,站点的目录数如下:
/usr/local/tomcat/webapps/test/
|-- WEB-INF
| |-- classes
| `-- lib
`-- index.jsp
3 directories, 1
file
<%@ page language=
"java"
%>
<html>
<
head
><title>TomcatA<
/title
><
/head
>
<body>
<h1><font color=
"red"
>TomcatA.example.com<
/h1
>
<table align=
"centre"
border=
"1"
>
<
tr
>
<td>Session ID<
/td
>
<% session.setAttribute(
"example.com"
,
"example.com"
); %>
<td><%= session.getId() %><
/td
>
<
/tr
>
<
tr
>
<td>Created on<
/td
>
<td><%= session.getCreationTime() %><
/td
>
<
/tr
>
<
/table
>
<
/body
>
<
/html
>
<%@ page language=
"java"
%>
<html>
<
head
><title>TomcatB<
/title
><
/head
>
<body>
<h1><font color=
"blue"
>TomcatB.example.com<
/h1
>
<table align=
"centre"
border=
"1"
>
<
tr
>
<td>Session ID<
/td
>
<% session.setAttribute(
"example.com"
,
"example.com"
); %>
<td><%= session.getId() %><
/td
>
<
/tr
>
<
tr
>
<td>Created on<
/td
>
<td><%= session.getCreationTime() %><
/td
>
<
/tr
>
<
/table
>
<
/body
>
<
/html
>
第四步:启动tomcat
catalina.sh start