怎么测试Tomcat是否安装配置成功

怎么测试Tomcat是否安装配置成功,第1张

打开Tomcat在服务器上的安装文件夹,

找到“bin”文件夹,

再双击上图中标出的exe文件,

当软件处于start状态时,在浏览器的地址栏中输入http://localhost:8080/,如果出现tomcat界面,说明安装配置成功。

Linux下Tomcat的安装配置

一.下载安装对应的jdk,并配置Java环境。

官网下载地址:

http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u26-download-400750.html

下载将jdk加压后放到/usr/local目录下:

[root@master ~]#chmod 755 jdk-6u5-linux-x64.bin

[root@master ~]# ./jdk-6u5-linux-x64.bin

[root@master ~]#mv jdk1.6.0_05 /usr/local

建立/usr/local/下的jdk软连接方便以后版本升级 :

[root@master ~]# ln -s /usr/local/jdk1.6.0_05/ /usr/local/jdk

配置环境变量:

在 /etc/profile 中加入以下内容:

JAVA_HOME=/usr/local/jdk1.6.0_05

JAVA_BIN=/usr/local/jdk1.6.0_05/bin

PATH=$PATH:$JAVA_BIN

CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export JAVA_HOME JAVA_BIN PATH CLASSPATH

保存退出

[root@master ~]source /etc/profile

查看java环境变量是否生效

[root@master ~]# java -version

java version "1.6.0_05"

Java(TM) SE Runtime Environment (build 1.6.0_05-b13)

Java HotSpot(TM) 64-Bit Server VM (build 10.0-b19, mixed mode)

测试成功

二.下载安装tomcat(http://tomcat.apache.org/)

[root@master ~]# unzip apache-tomcat-6.0.30.zip

[root@master ~]# mv apache-tomcat-6.0.30/ /usr/local/

[root@master ~]cd /usr/local/

[root@master local]# ln -s /usr/local/apache-tomcat-6.0.30/ /usr/local/tomcat

[root@master local]# cd tomcat/bin/

[root@master bin]#ls

[root@master bin]#vim catalina.sh

添加以下内容:

CATALINA_HOME=/usr/local/apache-tomcat-6.0.30/

[root@master local]#chmod +x *.sh

三.启动tomcat服务器

[root@master tomcat]# /usr/local/tomcat /bin/catalina.sh start

Using CATALINA_BASE: /usr/local/apache-tomcat-6.0.30/

Using CATALINA_HOME: /usr/local/apache-tomcat-6.0.30/

Using CATALINA_TMPDIR: /usr/local/apache-tomcat-6.0.30//temp

Using JRE_HOME:/usr/local/jdk1.6.0_05

Using CLASSPATH: /usr/local/apache-tomcat-6.0.30//bin/bootstrap.jar

[root@master logs]# cd /usr/local/tomcat/logs/

[root@master logs]# tail -f catalina.out

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:289)

at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

Jul 4, 2011 11:06:57 AM org.apache.coyote.http11.Http11Protocol pause

INFO: Pausing Coyote HTTP/1.1 on http-8080

Jul 4, 2011 11:06:58 AM org.apache.catalina.core.StandardService stop

INFO: Stopping service Catalina

Jul 4, 2011 11:06:58 AM org.apache.coyote.http11.Http11Protocol destroy

INFO: Stopping Coyote HTTP/1.1 on http-8080

四.在浏览器中输入

http://localhost:8080/(如果不是本机,则输入对应的ip地址)

测试出现tomcat页面则测试成功

ps:需要说明的是tomcat的默认测试页面是放在webapps下面,这个其实是在server.xml文件中配置的,如下所示:

<Host name="localhost" appBase="webapps"

unpackWARs="true" autoDeploy="true"

xmlValidation="false" xmlNamespaceAware="false">

[root@SOR_SYS apache-tomcat-6.0.30]# ls

LICENSE NOTICE RELEASE-NOTES RUNNING.txt bin conf lib logs temp webapps work

1)webapps文件夹主要用于web应用程序部署,比如你可以把你的应用程序包,如war文件拷到该目录下,容器会自动部署。

2)conf文件夹下主要是放置tomcat的服务器的相关配置文件

五。添加应用,再次进行测试

在webapps目录下放测试包(注意:webaapps目录下面主要是放应用包的.war在tomcat重启访问后会自动解压)

[root@master webapps]# pwd

/usr/local/tomcat/webapps

[root@master webapps]# tar -zxvf moni2.tar.gz

[root@master webapps]# ls

docs examples host-manager manager moni2 moni2.tar.gz ROOT

[root@master webapps]# /usr/local/tomcat/bin/catalina.sh start(重启tomcat)

Using CATALINA_BASE: /usr/local/apache-tomcat-6.0.30/

Using CATALINA_HOME: /usr/local/apache-tomcat-6.0.30/

Using CATALINA_TMPDIR: /usr/local/apache-tomcat-6.0.30//temp

Using JRE_HOME:/usr/local/jdk1.6.0_05

Using CLASSPATH: /usr/local/apache-tomcat-6.0.30//bin/bootstrap.jar

在浏览器中输入如下地址:

http://192.168.55.229:8080/moni2/

六。修改tomcat的监听端口

[root@master ~]# cd /usr/local/tomcat/conf

[root@master ~]# ls

[root@master ~]# vim server.xml

<Server port="8005" shutdown="SHUTDOWN">【停止tomcat时的端口】

<Connector port="8081" protocol="HTTP/1.1"

connectionTimeout="20000"

redirectPort="8443" />【tomcat默认的监听端口是8080,现在改成8081】

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />【apache+tomcat模式时访问tomcat的端口】

现在重启tomcat。访问http://192.168.55.229:8081/moni2/【注意:这时就需要修改端口了,嘿嘿。。。】

七。创建tomcat实例

假如我们现在使用的地址是:192..168.55.229,假如我们想在该机器上面创建tomcat实例,但是我们创建实例的脚本在服务器192.168.55.233上面上线,那么我们需要怎么做呢,请看以下步骤:

[root@master ~]# mount -t nfs 192.168.55.233:/opt/nfs /nfs【挂载目录】

[root@master ~]# cd /nfs/

[root@master nfs]# ls

tcfile

[root@master nfs]# cd tcfile/

[root@master tcfile]# ls

backupfile deployfile instancefile

[root@master instancefile]# ls

tomcatTemplate tomcatTemplate.zip

[root@master instancefile]# cd tomcatTemplate

[root@master tomcatTemplate]# ls

bin conf lib LICENSE logs NOTICE RELEASE-NOTES RUNNING.txt temp webapps work

[root@master tomcatTemplate]# cd bin

[root@master bin]# ls

bootstrap.jar commons-daemon.jarcreateResource.sh resource.properties startup.bat tool-wrapper.sh

c3p0.template commons-daemon-native.tar.gz digest.bat setclasspath.bat startup.shversion.bat

catalina.batcpappend.bat digest.sh setclasspath.sh tomcat-juli.jar version.sh

catalina.sh createInstance.sh encrypt.batshutdown.bat tomcat-native.tar.gz

catalina-tasks.xml createInstance.sh.bak encrypt.sh shutdown.sh tool-wrapper.bat

[root@master bin]# sh createInstance.sh tomcatServer229-1【创建实例】

/nfs/tcfile/instancefile/tomcatTemplate

New instance tomcatServer229-1 has successfully builded, and

shutdown.port=10001

ajp.port=8011

http.port=8081

https.port=8041

jmx.port=6901

[root@master bin]# cd /opt/oracle/tomcat/【可以在这个目录下面进行查看】

[root@master tomcat]# ls

tomcatServer229-1【命名规则,默认都是tomcat名字+-n表示第几个实例实际上是脚本中规定有格式】

[root@master tomcat]#

下载安装tomcat

[root@master ~]# unzip apache-tomcat-6.0.30.zip

[root@master ~]# mv apache-tomcat-6.0.30/ /usr/local/

[root@master ~]cd /usr/local/

[root@master local]# ln -s /usr/local/apache-tomcat-6.0.30/ /usr/local/tomcat

[root@master local]# cd tomcat/bin/

[root@master bin]#ls

[root@master bin]#vim catalina.sh

添加以下内容:

CATALINA_HOME=/usr/local/apache-tomcat-6.0.30/

[root@master local]#chmod +x *.sh

三.启动tomcat服务器

[root@master tomcat]# /usr/local/tomcat /bin/catalina.sh start

Using CATALINA_BASE:   /usr/local/apache-tomcat-6.0.30/

Using CATALINA_HOME:   /usr/local/apache-tomcat-6.0.30/

Using CATALINA_TMPDIR: /usr/local/apache-tomcat-6.0.30//temp

Using JRE_HOME:        /usr/local/jdk1.6.0_05

Using CLASSPATH:       /usr/local/apache-tomcat-6.0.30//bin/bootstrap.jar

[root@master logs]# cd /usr/local/tomcat/logs/

[root@master logs]# tail -f catalina.out

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:289)

at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

Jul 4, 2011 11:06:57 AM org.apache.coyote.http11.Http11Protocol pause

INFO: Pausing Coyote HTTP/1.1 on http-8080

Jul 4, 2011 11:06:58 AM org.apache.catalina.core.StandardService stop

INFO: Stopping service Catalina

Jul 4, 2011 11:06:58 AM org.apache.coyote.http11.Http11Protocol destroy

INFO: Stopping Coyote HTTP/1.1 on http-8080

四.在浏览器中输入

http://localhost:8080/(如果不是本机,则输入对应的ip地址)

测试出现tomcat页面则测试成功


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/11444205.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-16
下一篇 2023-05-16

发表评论

登录后才能评论

评论列表(0条)

保存