转自:http://blog.csdn.net/tongzidane/article/details/44035087
Linux下JDK和Tomcat安装
jdk,tomcat下载地址
http://www.oracle.com/technetwork/java/javase/downloads/index.htmlhttp://download.oracle.com/otn-pub/java/jdk/8u31-b13/jdk-8u31-linux-x64.tar.gz?AuthParam=1425274077_b32bf92a0bb67039ccba3e32e85fb356
查看环境变量
whereis javawhich java (java执行路径)
echo $JAVA_HOME
echo $PATH
二,安装jdk
选择要安装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
下载tomcatwget 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
(3)进入/usr/local/tomcat8/bin目录 ,启动tomcat
# cd/usr/local/tomcat8/
# cd bin/
#./startup.sh
(4)关闭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服务器,文件修改生效。