下载地址
http://www.oracle.com/technetwork/java/javase/downloads/index.html
http://download.oracle.com/otn-pub/java/jdk/8u31-b13/jdk-8u31-linux-x64.tar.gz?AuthParam=1425274077_b32bf92a0bb67039ccba3e32e85fb356
查看环境变量
whereis java
which java (java执行路径)
echo $JAVA_HOME
echo $PATH
二,安装
选择要安装java的位置,如/usr/目录下,新建文件夹java(mkdir java)
#mkdir -p /usr/java
拷贝下载的jdk-8u31-linux-x64.tar.gz到/usr/java下
#cd /usr/java
# tar -zxvf jdk-8u31-linux-x64.tar.gz
三、设置变量
# vim /etc/profile
在最后面添加如下内容:
# JAVA
JAVA_HOME=/usr/java/jdk1.8.0_31
CLASSPATH=.:$JAVA_HOME/lib.tools.jar
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME CLASSPATH PATH
使变量生效
# source /etc/profile
验证是否成功
# java -version
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
查看变量
# which java //java执行路径
/usr/java/jdk1.8.0_31/bin/java
# echo $JAVA_HOME
/usr/java/jdk1.8.0_31
# echo $PATH
/usr/java/jdk1.8.0_31/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
四. 卸载jdk
·找到jdk安装目录的_uninst子目录
·在shell终端执行命令./uninstall.sh即可卸载jdk。
五,安装tomcat
下载tomcat
wget http://mirrors.cnnic.cn/apache/tomcat/tomcat-8/v8.0.20/bin/apache-tomcat-8.0.20.tar.gz
(1)解压apache-tomcat-8.0.20.tar.gz
# tar-zxvf apache-tomcat-8.0.20.tar.gz
(2)复制解压后的目录apache-tomcat-8.0.20到/usr/local下并重命名为tomcat8
# cp -Rapache-tomcat-8.0.20 /usr/local/tomcat8
注意:/usr/local/tomcat8就是后面我们要修改环境变量时需要填写的目录路径
(3)
添加tomcat环境变量
# vim /etc/profile
加入下代码
#set environment variable
JAVA_HOME=/usr/java/jdk1.8.0_31
CLASSPATH=.:$JAVA_HOME/lib.tools.jar
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME CLASSPATH PATH
exportTOMCAT_HOME=/usr/local/tomcat8
exportCATALINA_HOME=/usr/local/tomcat8
修改应用环境变量,是配置生效
# source/etc/profile
(4)进入bin目录 ,启动tomcat
# cd/usr/local/tomcat8/
# cd bin/
#./startup.sh
(5)修改环境变量后重新启动tomcat启动成功
[root@oracledb bin]# ./startup.sh
Using CATALINA_BASE: /usr/local/tomcat8
Using CATALINA_HOME: /usr/local/tomcat8
Using CATALINA_TMPDIR: /usr/local/tomcat8/temp
Using JRE_HOME: /usr/java/jdk1.8.0_31
Using CLASSPATH: /usr/local/tomcat8/bin/bootstrap.jar:/usr/local/tomcat8/bin/tomcat-juli.jar
Tomcat started.
(6)关闭tomcat
[root@oracledb bin]# ./shutdown.sh
Using CATALINA_BASE: /usr/local/tomcat8
Using CATALINA_HOME: /usr/local/tomcat8
Using CATALINA_TMPDIR: /usr/local/tomcat8/temp
Using JRE_HOME: /usr/java/jdk1.8.0_31
Using CLASSPATH: /usr/local/tomcat8/bin/bootstrap.jar:/usr/local/tomcat8/bin/tomcat-juli.jar
(7) 查看进程
[root@oracledb bin]# ps -ef | grep tomcat
root 22552 1 99 09:58 pts/0 00:00:05 /usr/java/jdk1.8.0_31/bin/java -Djava.util.logging.config.file=/usr/local/tomcat8/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/tomcat8/endorsed -classpath /usr/local/tomcat8/bin/bootstrap.jar:/usr/local/tomcat8/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat8 -Dcatalina.home=/usr/local/tomcat8 -Djava.io.tmpdir=/usr/local/tomcat8/temp org.apache.catalina.startup.Bootstrap start
root 22581 22284 0 09:58 pts/0 00:00:00 grep tomcat
(8)添加管理权限
默认情况下,Tomcat并没提供具有管理权限的账号,所以需要添加具有这种权限的账号。角色manager-gui具有这种权限,但在系统用户控制文件tomcat-users.xml中并没有设置这两种角色和对应的用户,所以需要添加这种角色和用户,方法是打开tomcat-users.xml文件,添加如下内容:
<rolerolename="manager-gui"/>
<userusername="manager" password="manager"roles="manager-gui"/>
然后重启Tomcat服务器,文件修改生效。