我已经在Ubuntu 15.04系统上安装了TomCat 8,使用以下命令:
sudo apt-get install tomcat8 tomcat8-docs tomcat8-admin tomcat8-examples
安装目录是:
/usr/share/tomcat8/bin
所以我进入这个目录,并执行以下命令来启动服务器:
sudo ./startup.sh
我得到这个:
andrea@andrea-virtual-machine:/usr/share/tomcat8/bin$ sudo ./startup.sh
Using CATALINA_BASE: /usr/share/tomcat8
Using CATALINA_HOME: /usr/share/tomcat8
Using CATALINA_TMPDIR: /usr/share/tomcat8/temp
Using JRE_HOME: /usr/lib/jvm/java-8-oracle
Using CLASSPATH: /usr/share/tomcat8/bin/bootstrap.jar:/usr/share/tomcat8/bin/tomcat-juli.jar
Tomcat started.
所以我认为服务器已经启动。
问题是,如果我尝试打开这个URL http://localhost:8080/到浏览器中,我获得错误消息连接失败(我不知道它是正确的翻译在英语语言,因为我看到它在意大利语)。
如果我尝试打开此URL ****http://localhost**(没有8080端口规范),我获得Apache 2 web服务器信息页面(我将其用于一些PHP网站)。
如果我尝试执行TomCat关闭,我得到这个错误消息:
andrea@andrea-virtual-machine:/usr/share/tomcat8/bin$ sudo ./shutdown.sh
Using CATALINA_BASE: /usr/share/tomcat8
Using CATALINA_HOME: /usr/share/tomcat8
Using CATALINA_TMPDIR: /usr/share/tomcat8/temp
Using JRE_HOME: /usr/lib/jvm/java-8-oracle
Using CLASSPATH: /usr/share/tomcat8/bin/bootstrap.jar:/usr/share/tomcat8/bin/tomcat-juli.jar
lug 16, 2015 2:13:35 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
AVVERTENZA: Problem with directory [/usr/share/tomcat8/common/classes], exists: [false], isDirectory: [false], canRead: [false]
lug 16, 2015 2:13:35 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
AVVERTENZA: Problem with directory [/usr/share/tomcat8/common], exists: [false], isDirectory: [false], canRead: [false]
lug 16, 2015 2:13:35 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
AVVERTENZA: Problem with directory [/usr/share/tomcat8/server/classes], exists: [false], isDirectory: [false], canRead: [false]
lug 16, 2015 2:13:35 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
AVVERTENZA: Problem with directory [/usr/share/tomcat8/server], exists: [false], isDirectory: [false], canRead: [false]
lug 16, 2015 2:13:35 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
AVVERTENZA: Problem with directory [/usr/share/tomcat8/shared/classes], exists: [false], isDirectory: [false], canRead: [false]
lug 16, 2015 2:13:35 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
AVVERTENZA: Problem with directory [/usr/share/tomcat8/shared], exists: [false], isDirectory: [false], canRead: [false]
lug 16, 2015 2:13:35 PM org.apache.catalina.startup.Catalina stopServer
GRAVE: Catalina.stop:
java.io.FileNotFoundException: /usr/share/tomcat8/conf/server.xml (File o directory non esistente)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:427)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:400)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:487)
那么问题是什么呢?我错过了什么?我该怎么补救呢?
Tnx
当您使用apt在Ubuntu中安装Tomcat时,它是作为服务安装的。要启动和停止它,您应该使用以下命令:
sudo service tomcat8 start
sudo service tomcat8 stop
您也可以使用此命令查看其当前状态:
sudo service tomcat8 status
在尝试此操作之前,您可能需要重新启动以确保没有任何其他Tomcat进程在后台运行。