做下总结。方便以后查阅,给自己加深一下印象,同时也希望给出现相同错误的亲们提供一个解决方案。
可以进入下面的网站下载需要的版本
1.下载jdk及tomcat
http://download.chinaunix.net/down.php?id=33932&ResourceID=61&site=1
http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-6/v6.0.36/bin/apache-tomcat-6.0.36.tar.gz
2.安装jdk环境
[root@localhost src]# ls
apache-tomcat-6.0.36.tar.gz debug jdk-6u26-dlj-linux-amd64.bin kernels
[root@localhost src]#./jdk-6u26-dlj-linux-amd64.bin //执行后会有大堆提示信息,到后面会有如下提示你是否同样执行:
Do you agree to the above license terms? [yes or no]
我们执行 yes
[root@localhost src]# ls
apache-tomcat-6.0.36.tar.gz jdk1.6.0_26 kernels
debug jdk-6u26-dlj-linux-amd64.bin
[root@localhost src]# mkdir -p /usr/java/ //新建一个目录,用来搭建jdk环境
[root@localhost src]#vim /etc/profile //修改环境变量,在改文件下面添加以下内容:
export JAVA_HOME=/usr/java/jdk1.6.0_26
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOMR/bin
source /etc/profile //使环境变量马上生效
java -version //查看java版本,来观察jdk是否安装成功
3.安装配置tomcat
[root@localhost src]#tar zxvf apache-tomcat-6.0.36.tar.gz
[root@localhost src]# mv apache-tomcat-6.0.36 /usr/local/tomcat_1
[root@localhost src]# cd /usr/local/tomcat_1/
[root@localhost tomcat_1]# ls
bin lib logs RELEASE-NOTES temp work
conf LICENSE NOTICE RUNNING.txt webapps
[root@localhost tomcat_1]# ./bin/startup.sh //启动tomcat
Using CATALINA_BASE: /usr/local/tomcat_1
Using CATALINA_HOME: /usr/local/tomcat_1
Using CATALINA_TMPDIR: /usr/local/tomcat_1/temp
Using JRE_HOME: /usr/java/jdk1.6.0_26
Using CLASSPATH: /usr/local/tomcat_1/bin/bootstrap.jar
root@localhost lib]# ps -ef |grep java |grep -v grep //查看是否有java进程
如果java进程起来,且8080端口启动即表示tomcat正常启动:访问:http://ip:8080
[root@localhost tomcat_1]# java //执行java命令
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object //报错,貌似提示在初始化的时候虚拟内存vm错误
[root@localhost tomcat_1]# cd /usr/java/jdk1.6.0_26/lib/
[root@localhost lib]# ls
ct.sym htmlconverter.jar jconsole.jar orb.idl tools.pack
dt.jar ir.idl jexec sa-jdi.jar visualvm
[root@localhost lib]# cd /usr/java/jdk1.6.0_26/jre/lib/
[root@localhost lib]# ls
[root@localhost lib]# /usr/local/tomcat_1/bin/startup.sh //再次尝试启动tomcat
Using CATALINA_BASE: /usr/local/tomcat_1
Using CATALINA_HOME: /usr/local/tomcat_1
Using CATALINA_TMPDIR: /usr/local/tomcat_1/temp
Using JRE_HOME: /usr/java/jdk1.6.0_26
Using CLASSPATH: /usr/local/tomcat_1/bin/bootstrap.jar
[root@localhost lib]# netstat -ntl //查看tomcat的8080端口是否已经启动
Active Internet connections (only servers)
ok,我们的8080端口已经起来。
[root@localhost lib]# ps -ef |grep java |grep -v grep //查看是否有java进程
root 11454 1 0 09:31 pts/0 00:00:08 /usr/java/jdk1.6.0_26/bin/java -Djava.util.logging.config.file=/usr/local/tomcat_1/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/tomcat_1/endorsed -classpath /usr/local/tomcat_1/bin/bootstrap.jar -Dcatalina.base=/usr/local/tomcat_1 -Dcatalina.home=/usr/local/tomcat_1 -Djava.io.tmpdir=/usr/local/tomcat_1/temp org.apache.catalina.startup.Bootstrap start
ok,进程也有了,接下来我们在浏览器里面来查看是否可以进行访问:
ok,我们的apache故障已解决,已能访问。