红联Linux门户
Linux帮助

Tomcat for Linux安装

发布时间:2015-05-07 15:55:45来源:linux网站作者:avilifans

下载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

Tomcat for Linux安装


为了测试,特地请同事帮我写了点代码

/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.测试页面


相关文章:
Ubuntu配置Tomcat:http://www.linuxdiyf.com/linux/10809.html

Linux(CentOS)下配置安装Tomcat并配置JDK环境:http://www.linuxdiyf.com/linux/11513.html

CentOS 6.4安装搭建Tomcat 7:http://www.linuxdiyf.com/linux/10513.html