Tomcat搭建&配置

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/
相關文章
相關標籤/搜索