JDK安装&环境变量配置
官网下载JDK
.tar.gz
安装JDK
tar -zxvf jdk-8u31-linux-i586.tar.gz
mv jdk1.8.0_31 /usr/local
配置环境变量
vim /etc/profile,在尾部加上以下内容
JAVA_HOME=/usr/local/jdk1.8.0_31
JAVA_BIN=/usr/local/jdk1.8.0_31/bin
PATH=$PATH:$JAVA_BIN
CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH
刷新配置文件
source /etc/profile
测试安装的java
java -version
Tomcat安装
官网下载tomcat
tar -zxvf apache-tomcat-7.0.57.tar.gz
mv apache-tomcat-7.0.57 /usr/local
配置tomcat
vim /etc/profile,在尾部加上以下内容
export TOMCAT_HOME=/usr/local/apache-tomcat-7.0.57
vim /usr/local/apache-tomcat-7.0.57/bin/catalina.sh,在尾部加上以下内容
CATALINA_HOME=/usr/local/apache-tomcat-7.0.57
刷新配置文件
source /etc/profile
cd /usr/local/apache-tomcat-7.0.57/bin/
chmod 777 *.sh
启动服务器
bash catalina.sh start
或 /usr/local/apache-tomcat-7.0.57/bin/catalina.sh start
注:如果在启动过程出现下列错误
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
解决方法:
tomcat的startup.bat,调用了catalina.bat,而catalina.bat则调用了setclasspath.bat。只要在setclasspath.bat的开头声明环境变量,打开tomcat的bin目录下面的setclasspath.sh,添加后内容如下
# -----------------------------------------------------------------------------
# Set JAVA_HOME or JRE_HOME if not already set, ensure any provided settings
# are valid and consistent with the selected start-up options and set up the
# endorsed directory.
# -----------------------------------------------------------------------------
export JAVA_HOME=/usr/local/jdk1.8.0_31
exprot JRE_HOME=/usr/local/jdk1.8.0_31/jre
# Make sure prerequisite environment variables are set
if [ -z "$JAVA_HOME" -a -z "$JRE_HOME" ]; then
tomcat测试
在浏览器中输入,http://ip:8080/