1、
jdk下载地址:
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
tomcat下载地址:
http://tomcat.apache.org/download-70.cg
2、jdk安装与配置.(rpm包)
(1)jdk安装
rpm包:
# rpm -ivh jdk-7u79-linux-x64.rpm
tar.gz包:解压缩
# mkdir /usr/local/java
# cd /usr/local/java
# tar -zxvf /software/jdk-7u79-linux-x64.tar.gz
生成链接以便版本升级
# ln -s jdk1.7.0_79 latest
# ln -s latest default
(2)配置环境变量
# vi /etc/profile
export JAVA_HOME=/usr/local/java/default
export JAVA_BIN=$JAVA_HOME/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
使配置生效
# source /etc/profile
测试jdk.
# java -version
java version "1.7.0_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)
查看jdk时出现以下错误解决办法:
3、Tomcat的安装
解压缩
# mkdir /usr/local/tomcat
# cd /usr/local/tomcat
# tar -zxvf /software/apache-tomcat-7.0.70.tar.gz
生成链接以便版本升级
# ln -s apache-tomcat-7.0.70 server
启动Tomcat
# cd /usr/local/tomcat/server/bin
# ./startup.sh
Using CATALINA_BASE: /usr/local/tomcat/server
Using CATALINA_HOME: /usr/local/tomcat/server
Using CATALINA_TEMDIR: /usr/local/tomcat/server/temp
Using JRE_HOME: /usr/java/default
Using CLASS_PATH: /usr/local/tomcat/server/bin/bootstrap.jar:/usr/local/tomcat/server/bin/tomcat-juli.jar
Tomcat started.
4、 测试Tomcat:
打开防火墙,使外部能访问(centos6下)
# /sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
# service iptables save
# service iptables restart
或直接修改文件/etc/sysconfig/iptables.
# vi /etc/sysconfig/iptables
-A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
# service iptables restart
打开防火墙,使外部能访问(centos7下)
firewall-cmd --permanent --zone=public --add-port=8080/tcp #添加端口
firewall-cmd --reload #重新加载
firewall-cmd --list-all #查看一下
在浏览器输入: http://192.168.170.128:8080
如在本机可以输入: http://localhost:8080
出现tomcat的页面表示安装成功.
停止Tomcat
# ./shutdown.sh