tomcat安装

tomcat安装
卸载默认java和jdk(不做卸载安装后java会有问题)

软件:
apr-1.4.6.tar.bz2
apr-iconv-1.2.0.tar.gz
apr-util-1.5.2.tar.gz

jdk-6u13-linux-i586-rpm.bin
apache-tomcat-7.0.33-src.tar.gz
相关下载地址:
http://archive.apache.org/dist/apr
http://mirror.bjtu.edu.cn/apache/tomcat/tomcat-7/v7.0.16/bin/apache-tomcat-7.0.16.tar.gz

安装
1.1.安装apr
#tar xvf apr-1.4.6.tar.bz2
#cd apr-1.4.6.tar
#./configure --prefix=/usr/local/www/apr
#make
#make install

1.2.安装apr-iconv
#tar xvf apr-iconv-1.2.0.tar.gz
#cd apr-iconv-1.2.0.tar.gz
#./configure --prefix=/usr/local/www/apr-iconv --with-apr=/usr/local/www/apr
#make
#maek install

1.3.安装apr-util-1.5.2.tar.gz
#tar -xvf apr-util-1.5.2.tar.gz
#cd apr-util-1.5.2.tar.gz
#./configure --prefix=/usr/local/www/apr-util  --with-apr=/usr/local/www/apr --with-apr-iconv=/usr/local/www/apr-iconv/bin/apriconv  
#make
#make install

2.1.安装jdk
#./jdk-6u13-linux-i586-rpm.bin
#ln -s /usr/java/jdk1.6.0_25 /usr/local/java

2.2.设置环境变量
#vi /etc/profile
export JAVA_HOME=/usr/local/java
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

3.1.安装tomcat
# tar -zxvf apache-tomcat-7.0.33-src.tar.gz
 # mv apache-tomcat-7.0.33-src /usr/local/tomcat
 # vi /usr/local/tomcat/bin/catalina.sh

加入一行:

JAVA_HOME=/usr/local/java
 # /usr/local/tomcat/bin/startup.sh

3.2.安装tomcat-native
安装好tomcat7之后,tomcat-native已经在tomcat的bin目录下了,可以直接使用
 # cd /usr/local/www/tomcat/bin  
# tar zxvf tomcat-native.tar.gz
# cd tomcat-native-1.1.27-src/jni/native  
# ./configure --with-apr=/usr/local/www/apr --with-java-home=/usr/local/java
# make  
# make install  

3.3.设置 apr 的环境变量:
# vi /etc/profile  
后面添加以下内容    
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib

启动tomcat
#/usr/local/tomcat/bin/startup.sh
若启动失败查看日志  #tail -f /usr/local/tomcat/logs/catalina.out
百度google找原因吧


常见问题:
1.安装源码安装时特别注意是否有完整的.jar包,典型报错信息:
 Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/catalina/startup/Bootstrap
 Caused by: java.lang.ClassNotFoundException: org.apache.catalina.startup.Bootstrap
         at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
 Could not find the main class: org.apache.catalina.startup.Bootstrap.  Program will exit.
  处理方式:添加.jar包或者重新下载完整的tomcat包
2.修改默认的/etc/hosts
 SEVERE: StandardServer.await: create[localhost:8005]:
 java.net.BindException: Cannot assign requested address
        at java.net.PlainSocketImpl.socketBind(Native Method)
        at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359)
         at java.net.ServerSocket.bind(ServerSocket.java:319)
        at java.net.ServerSocket.<init>(ServerSocket.java:185)
        at org.apache.catalina.core.StandardServer.await(StandardServer.java:427)
        at org.apache.catalina.startup.Catalina.await(Catalina.java:766)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:712)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:456)
   处理方式:恢复/etc/hosts默认值
 127.0.0.1               localhost.localdomain localhost


3.jdk安装过程中一些.jar文件有时候会以.pack形式打包,需要解压成.jar形式的文件;


4.tomcat无法启动是,关注lib下jar文件,每个下载的软件包包含的jar不同,有的甚至没有,需要

 下载后才能启动


你可能感兴趣的:(tomcat安装)