1、安装jdk(下载到当前路径)
下载jdk8:
wget http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz解压出现问题(主要是用wget 直接下载orcale的jdk地址是不行的,直接复制链接在浏览器中访问试试就知道了 http:302),所以一出现以下问题
cgc@cgc:~$ tar -xvf jdk-8u131-linux-x64.tar.gz tar: 谨慎地拒绝创建空归档文件 Try 'tar --help' or 'tar --usage' for more information.解决办法:
直接用浏览器点击下载下来再进行操作(-_-||)。
配置java环境变量
cgc@cgc:~$ sudo cp -r jdk1.8.0_131 /usr/local/
cgc@cgc:~$ sudo vim /etc/profile
在/etc/profile 末尾部添加以下配置
#set java Environment JAVA_HOME=/usr/local/jdk1.8.0_131 PATH=$JAVA_HOME/bin:$PATH CLASSPATH=:.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export JAVA_HOME export PATH export CLASSPATH
然后让刚改的配置生效
cgc@cgc:~$ source /etc/profile cgc@cgc:~$ cgc@cgc:~$ echo $JAVA_HOME /usr/local/jdk1.8.0_131
cgc@cgc:~$ java -version java version "1.8.0_131" Java(TM) SE Runtime Environment (build 1.8.0_131-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11,mixed mode)
java环境配置结束!
二、安装及配置tomcat
cgc@cgc:~$sudo ln -s /usr/local/jdk1.8.0_131/ /usr/local/jdk cgc@cgc:~$sudo unzip -d /usr/local/ apache-tomcat-8.0.23.zip cgc@cgc:~$sudo ln -s /usr/local/apache-tomcat-8.0.23/ /usr/local/tomcat在tomcat/bin/catalina.sh中添加
##=============set==by====myselsf======================== #include java Environment export JAVA_HOME=/usr/local/jdk export JRE_HOME=/usr/local/jdk/jre #set tomcat home CATALINA_HOME=/usr/local/apache-tomcat-8.0.23/ ##=============set==by====myselsf========================
cgc@cgc:~$ cd /usr/local/tomcat/bin/ cgc@cgc:~$ chmod +x *.sh cgc@cgc:~$ sudo ./startup.sh Using CATALINA_BASE: /usr/local/apache-tomcat-8.0.23/ Using CATALINA_HOME: /usr/local/apache-tomcat-8.0.23/ Using CATALINA_TMPDIR: /usr/local/apache-tomcat-8.0.23//temp Using JRE_HOME: /usr/local/jdk/jre Using CLASSPATH: /usr/local/apache-tomcat-8.0.23//bin/bootstrap.jar:/usr/local/apache-tomcat-8.0.23//bin/tomcat-juli.jar Tomcat started.tomcat配置完毕! 原文链接:https://www.f2er.com/ubuntu/353212.html