unbantu:
1、下载相应版本的jdk及tomcat:sudo wget ${url}
2、解压:
tar zxvf jdk-7u79-linux-x64.tar.gz
tar zxvf apache-tomcat-7.0.70.tar.gz
为了方便管理,移到指定目录:
sudo mv jdk1.7.0_79/ /usr/lib/jvm/jdk1.7
sudo mv apache-tomcat-7.0.70.tar.gz /usr/lib/tomcat/tomcat7
3、设置jdk环境变量:vim ~/.bashrc
在文件末尾加上以下代码:
export JAVA_HOME=/usr/lib/jvm/jdk1.7
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
执行以下命令让修改立即生效:long@ubuntu:/usr/lib/jvm$ source ~/.bashrc
4、验证jdk是否安装成功: java -version
centos(rpm安装):
1、wget --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.rpm
2、rpm -ivh jdk-8u171-linux-x64.rpm
Tomcat:
5、设置tomcat的jdk信息:vim ./bin/catalina.sh
在下图所示位置添加如下代码:
JAVA_HOME=/usr/lib/jvm/jdk1.7
JAVA_OPTS="-server -Xms512m -Xmx1024m -XX:PermSize=600M -XX:MaxPermSize=600m -Dcom.sun.management.jmxremote"
6、验证tomcat是否安装成功:./bin/startup.sh