无法在 ubuntu 中启动 tomcat6 服务器

无法在 ubuntu 中启动 tomcat6 服务器

我首先下载的open-jdk是:

sudo apt-get install openjdk-6-jdk

当我写作时,java -version我得到:

java version "1.7.0_09"
OpenJDK Runtime Environment (IcedTea7 2.3.4) (7u9-2.3.4-0ubuntu1.12.10.1)
OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode)

当我写的时候javac -version我得到:

javac 1.6.0_24

然后我从http://www.poolsaboveground.com/apache/tomcat/tomcat-6/v6.0.36/bin/apache-tomcat-6.0.36.tar.gz

我解压了文件,并尝试在目录sudo bash startup.sh中运行/bin。然后我收到以下消息:

Using CATALINA_BASE:   /home/apache-tomcat-6.0.36
Using CATALINA_HOME:   /home/apache-tomcat-6.0.36
Using CATALINA_TMPDIR: /home/apache-tomcat-6.0.36/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /home/apache-tomcat-6.0.36/bin/bootstrap.jar

我也尝试将 Tomcat 安装为服务,然后sudo apt-get install tomcat6收到消息:

sudo apt-get install tomcat6
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
...
Use 'apt-get autoremove' to remove them.
Suggested packages:
  tomcat6-docs tomcat6-admin tomcat6-examples tomcat6-user libtcnative-1
The following NEW packages will be installed:
  tomcat6
0 upgraded, 1 newly installed, 0 to remove and 28 not upgraded.
Need to get 0 B/30.2 kB of archives.
After this operation, 258 kB of additional disk space will be used.
Preconfiguring packages ...
Selecting previously unselected package tomcat6.
(Reading database ... 85488 files and directories currently installed.)
Unpacking tomcat6 (from .../tomcat6_6.0.35-5_all.deb) ...
Processing triggers for ureadahead ...
Setting up tomcat6 (6.0.35-5) ...
* Starting Tomcat servlet engine tomcat6                  [fail]
invoke-rc.d: initscript tomcat6, action "start" failed.

当我运行这个时:

$ sudo /etc/init.d/tomcat6 start
 * Starting Tomcat servlet engine tomcat6        [fail]

服务器就是无法启动。我在 Windows 中进行了完全相同的设置,运行startup.bat,并且成功了。有人知道问题出在哪里吗?没有错误消息。

答案1

我在 Ubuntu 上也遇到过这种情况。

为了解决这个问题,我首先使用 apt 清理/重新安装了 tomcat6

sudo apt-get --purge remove tomcat6 tomcat6-common tomcat6-admin
sudo apt-get install tomcat6 tomcat6-common tomcat6-admin

然后使用以下方式启动:

sudo /etc/init.d/tomcat6 restart

然后当出现失败信息时检查错误日志:

tail /var/log/tomcat6/catalina.2013-05-03.log

遇到了一些缺少目录的问题,因此修复了这些问题,每次都重新启动,直到这里不再出现错误。

然后检查输出日志:

tail /var/log/tomcat6/catalina.out

这显示了一些 Java 错误(缺少类)。

经过一番搜索,发现未设置环境变量可能会导致问题,通过在 /etc/environment 中添加以下两行可以解决问题:

CATALINA_HOME=/usr/share/tomcat6
CATALINA_BASE=/var/lib/tomcat6

然后导入这些/检查:

source /etc/environment
echo $CATALINA_HOME

还使用以下方法修复了 lib 符号链接:

cd /var/lib/tomcat6
sudo ln -s /usr/share/java lib

完成所有这些操作后,下次重启就可以了,现在我可以通过导航到以下地址看到“It Works!”页面:

http://localhost:8080/

相关内容