首页 > 代码库 > linux install java and tomcat

linux install java and tomcat



在官网下载jdk tar包和tomcat tar包

[root@localhost ~]# mkdir /usr/local/java
[root@localhost ~]# tar -zxvf jdk-8u25-linux-x64.tar.gz
[root@localhost ~]# mv jdk1.8.0_25/* /usr/local/java/
设置java 环境变量
[root@localhost ~]# cp /etc/profile /etc/profile.bk
[root@localhost ~]# vi /etc/profile
export JAVA_HOME=/usr/local/java
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
"/etc/profile" 82L, 1949C written
[root@localhost ~]# source /etc/profile
测试java 是否成功
[root@localhost ~]# java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
[root@localhost ~]# tar -zxvf apache-tomcat-8.0.15.tar.gz
安装tomcat
[root@localhost ~]# mkdir /usr/local/tomcat
[root@localhost ~]# mv apache-tomcat-8.0.15
apache-tomcat-8.0.15/        apache-tomcat-8.0.15.tar.gz  
[root@localhost ~]# mv apache-tomcat-8.0.15/* /usr/local/tomcat/
设置tomcat 环境路径变量,catalina.sh 文件最后添加
[root@localhost ~]# vi /usr/local/tomcat/bin/catalina.sh

CATALINA_HOME=/usr/local/tomcat/
"/usr/local/tomcat/bin/catalina.sh" 581L, 21395C written
设置 脚本权限
[root@localhost ~]# chmod +x /usr/local/tomcat/bin/*.sh
[root@localhost ~]# /usr/local/tomcat/bin/startup.sh
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr/local/java/jre
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
设置防火墙
[root@localhost ~]# iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
[root@localhost ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables: [  OK  ]
[root@localhost ~]# service iptables restart
iptables: Flushing firewall rules: [  OK  ]
iptables: Setting chains to policy ACCEPT: filter [  OK  ]
iptables: Unloading modules: [  OK  ]
iptables: Applying firewall rules: [  OK  ]
开启服务
[root@localhost ~]# ps -ef | grep java
root      2743     1 15 01:30 pts/1    00:00:11 /usr/local/java/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/tomcat/endorsed -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start
root      2872  2636  1 01:31 pts/1    00:00:00 grep java
[root@localhost ~]# netstat -ano | grep 8080
tcp        0      0 :::8080                     :::*                        LISTEN      off (0.00/0/0)
tcp        0      0 ::ffff:192.168.98.194:8080  ::ffff:192.168.98.173:64260 TIME_WAIT   timewait (54.27/0/0)
tcp        0      0 ::ffff:192.168.98.194:8080  ::ffff:192.168.98.173:64261 TIME_WAIT   timewait (54.27/0/0)
[root@localhost ~]# /usr/local/tomcat/bin/shutdown.sh
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr/local/java/jre
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[root@localhost ~]# /usr/local/tomcat/bin/startup.sh
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr/local/java/jre
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@localhost ~]#

本文出自 “左丿仔” 博客,请务必保留此出处http://zuopiezi.blog.51cto.com/4831427/1595610

linux install java and tomcat