tomcat for linux 安装
下载tomcat
wget http://apache.mirrors.tds.net/tomcat/tomcat-7/v7.0.42/bin/apache-tomcat-7.0.42.tar.gz
下载jdk
wget http://download.oracle.com/otn-pub/java/jdk/7u40-b43/jdk-7u40-linux-x64.rpm?AuthParam=1380156785_0ca1938e622ee55dad3148c1442358b3
[root@localhost src]# mv jdk-7u40-linux-x64.rpm\?AuthParam\=13801567
85_0ca1938e622ee55dad3148c1442358b3 jdk-7u40-linux-x64.rpm
[root@localhost src]# rpm -ivh jdk-7u40-linux-x64.rpm
[root@localhost src]# export JAVA_HOME=/usr/java/jdk1.7.0_40
[root@localhost src]# export JAVA_BIN=/usr/java/jdk1.7.0_40/bin
[root@localhost src]# export PATH=$PATH:$JAVA_HOME/bin
[root@localhost src]# export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
[root@localhost src]# export JAVA_HOME JAVA_BIN PATH CLASSPATH
[root@localhost src]# java -version
java version "1.7.0_40"
这也正是临时生效,所以,我们需要把这些配置导入到/etc/profile
[root@localhost src]#echo "export JAVA_HOME=/usr/java/jdk1.7.0_40" >> /etc/profile
[root@localhost src]#echo "export JAVA_BIN=/usr/java/jdk1.7.0_40/bin" >> /etc/profile
[root@localhost src]#echo "export PATH=$PATH:$JAVA_HOME/bin" >> /etc/profile
[root@localhost src]#echo " export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar" >> /etc/profile
[root@localhost src]# echo "export JAVA_HOME JAVA_BIN PATH CLASSPATH" >> /etc/profile
[root@localhost bin]# echo "export TOMCAT_HOME=/usr/local/tomcat" >> /etc/profile
[root@localhost src]#source /etc/profile
[root@localhost bin]# pwd
/usr/local/tomcat/bin
[root@localhost bin]# ./startup.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.7.0_40
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
http://127.0.0.1:8080
为了测试,特地请同事帮我写了点代码
/usr/local/tomcat/webapps/ceshi/ceshi
[root@localhost ceshi]# cat index.jsp
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>测试页面</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
This is my JSP page.测试页面 <br>
</body>
</html>
http://127.0.0.1:8080/ceshi/ceshi/index.jsp
This is my JSP page.测试页面