环境:Ubuntu12.04 64位
需要安装:
1. java jdk
2. apache-tomcat7
1.安装并配置java jdk
(1)官网下载JDK
地址: http://www.oracle.com/technetwork/articles/javase/index-jsp-138363.html
在Java SE Development Kit 下选择对应版本的JDK.与你的操作系统对应。
(2)解压
解压jdk-8u121-linux-x64.tar.gz,并把解压后的文件放到/usr/lib/jvm目录下
sudo tar -zxvf jdk-8u121-linux-x64.gz -C /usr/lib/jvm
(3)修改环境变量
sudo vim ~/.bashrc
#set oracle jdk environment export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_121 ## 这里要注意目录要换成自己解压的jdk 目录 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH
使环境变量马上生效:
source ~/.bashrc
(4)测试是否安装成功
java -version
会显示java的版本号:
java version "1.8.0_121" Java(TM) SE Runtime Environment (build 1.8.0_121-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13,mixed mode)
2. 安装tomcat7
(1)下载tomcat7
这里下载的是:apache-tomcat-7.0.77.tar.gz
(2)解压
tar -zxvf apache-tomcat-7.0.77.tar.gz重命名为tomcat7
mv apache-tomcat-7.0.77 tomcat7将tomcat7文件夹移到/usr/local目录下:
sudo mv tomcat7 /usr/local/
(3)设置环境变量:
sudo gedit /etc/profile在文件末尾中加入:
#set tomcat environment CATALINA_HOME=/usr/local/tomcat7 export CATALINA_HOME保存
进入tomcat7文件夹:
sudo gedit bin/catalina.sh
CATALINA_HOME=/usr/local/tomcat7 JAVA_HOME=/usr/local/java/jdk1.8.0_121
CATALINA_HOME是 tomcat7的安装路径,JAVA_HOME是上面JDK的安装路径
(4)启动tomcat
Using CATALINA_BASE: /usr/local/tomcat7 Using CATALINA_HOME: /usr/local/tomcat7 Using CATALINA_TMPDIR: /usr/local/tomcat7/temp Using JRE_HOME: /usr/local/java/jdk1.8.0_121 Using CLASSPATH: /usr/local/tomcat7/bin/bootstrap.jar:/usr/local/tomcat7/bin/tomcat-juli.jar Tomcat started.
停止tomcat:
sudo ./bin/shutdown.sh
(5)检测是否安装成功:
浏览器访问http://localhost:8080/会显示tomcat7的信息