centos tomcat安装
1.下载tomcat
cd usr/local
wget http://apache.fayea.com/tomcat/tomcat-7/v7.0.70/bin/apache-tomcat-7.0.70.tar.gz
2.
tar -zxv -f apache-tomcat-7.0.70.tar.gz //解压安装包
rm -rf apache-tomcat-7.0.70.tar.gz //删除压缩包
mv apache-tomcat-7.0.70 tomcat //重命名文件
3.启动tomcat
/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/lib/jvm/java-1.7.0-openjdk-1.7.0.111.x86_64 Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar Tomcat started.
4.关闭tomcat
/usr/local/tomcat/bin/shutdown.sh
--------------------------------------------------------------------------------------
在这里我遇到了一个棘手的问题,端口已打开,tomcat已启动,但就是启动失败了
去启动记录中查看启动记录
Aug 15, 2016 2:51:22 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib Exception in thread "main" java.lang.InternalError at sun.security.ec.SunEC.initialize(Native Method) at sun.security.ec.SunEC.access$000(SunEC.java:49) at sun.security.ec.SunEC$1.run(SunEC.java:61) at sun.security.ec.SunEC$1.run(SunEC.java:58) at java.security.AccessController.doPrivileged(Native Method) at sun.security.ec.SunEC.<clinit>(SunEC.java:58) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at java.lang.Class.newInstance(Class.java:383) at sun.security.jca.ProviderConfig$2.run(ProviderConfig.java:221) at sun.security.jca.ProviderConfig$2.run(ProviderConfig.java:206) at java.security.AccessController.doPrivileged(Native Method) at sun.security.jca.ProviderConfig.doLoadProvider(ProviderConfig.java:206) at sun.security.jca.ProviderConfig.getProvider(ProviderConfig.java:187) at sun.security.jca.ProviderList.loadAll(ProviderList.java:282) at sun.security.jca.ProviderList.removeInvalid(ProviderList.java:299) at sun.security.jca.Providers.getFullProviderList(Providers.java:173) at java.security.Security.getProviders(Security.java:456) at org.apache.catalina.core.JreMemoryLeakPreventionListener.lifecycleEvent(JreMemoryLeakPreventionListener.java:410) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:394) at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:99) at org.apache.catalina.startup.Catalina.load(Catalina.java:642) at org.apache.catalina.startup.Catalina.load(Catalina.java:667) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:253) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:427)
但看来看去都不知道是什么原因的导致的,最后问大神
因为我使用yum 安装的Jdk
openjdk导致缺少了一些jar包 大神让我装一下oracle jdk
装完后,立马就好了 !!! 哎... 心疼。。
下面是安装oracle JDK 流程
安装之前请确认是否已安装了JDK
我的是yum安装的 不是和我一样的,请自行百度删除java JDK
yum -y remove java-1.7.0-openjdk* yum -y remove tzdata-java.noarch
1.下载安装JDK
http://www.oracle.com/technetwork/java/javase/downloads/index.html
选择合适的网址
先抓包获取实际下载地址
wget http://download.oracle.com/otn-pub/java/jdk/7u60-b19/jdk-7u65-linux-x64.tar.gz?AuthParam=1406381642_d498d95482a71eaad9c5c240d100e2a0
重命名并解压
mv jdk-8u101-linux-x64.tar.gz?AuthParam=1471273728_d6cd73c47f6388973c77ebd246240de9 jdk-8u101-linux-x64.tar.gz
tar -xzvf jdk-8u101-linux-x64.tar.gz
移动文件
mv jdk1.8.0_101 /usr/local/java
2.配置环境变量
vi /etc/profile
最后加入代码
export JAVA_HOME=/usr/java export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin
退出后保存环境变量
source /etc/profile
检测是否成功
java -version
-------------------------------------------------------------------------------------------------------------------------