tomcat在终端启动,但在ubuntu上不能在浏览器中运行?

disho6za  于 2023-04-11  发布在  其他
关注(0)|答案(7)|浏览(159)

我手动安装了tomcat 7。
它运行在终端上(tomcat启动)。
但是当我试图在浏览器(localhost:8080)上运行它时,页面html出现了。
我找不到问题出在哪里
Java版本“1.7.0_79”OpenJDK运行环境(IcedTea 2.5.5)(7 u 79 -2.5.5-0ubuntu0.14.04.2)OpenJDK服务器VM(build 24.79-b 02,混合模式)
使用 Catalina _BASE:/opt/tomcat/
使用 Catalina _HOME:/opt/tomcat/
使用 Catalina _TMPDIR:/opt/tomcat//temp
使用JRE_HOME:/usr/lib/jvm/java-1.7.0-openjdk-i386
使用CLASSPATH:
/opt/tomcat//bin/bootstrap. jar:/opt/tomcat//bin/tomcat-juli.jar Tomcat已启动。
谢谢你

ffx8fchx

ffx8fchx1#

如果在tomcat启动期间发生任何错误,那么该tomcat错误不会显示在ubuntu终端上。因此,您需要从以下位置检查日志文件。

{tomcat path}/logs/catalina.{date}.log

{tomcat path} = tomcat安装路径。
{date} =日期日志。

carvr3hs

carvr3hs2#

好吧,现在这听起来可能很傻,但这个问题也发生在我身上。经过大量的脑力劳动,我得出了这个解决方案。
只需在./startup.sh之前添加sudo
使用以下命令从Tomcat bin目录启动tomcat服务器:
$ sudo ./startup.sh
希望这能帮上忙。

k4emjkb1

k4emjkb13#

检查JAVA环境设置是否正确;它需要Java在机器上运行。

0lvr5msh

0lvr5msh4#

检查这些详细信息:

1)Tomcat在哪个端口运行

a)通过netstat命令检查是否知道tomcat的PID:例如,我可以看到我的tomcat的PID是1483。因此使用,
$ sudo netstat -lnp | grep 1483我可以看到它在哪个端口上运行/使用。
B)Tomcat内部:在tomcat的conf目录下的server.xml中检查这一行:
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>

2)检查浏览器是否开启了Proxy设置。
**3)检查是否可以通过localhost或ip地址或机器名访问。**例如http://localhost:8080http://pc-name:8080http://192.168.1.1:8080

4)最后,检查firewall / iptables,如果可能的话,暂时禁用它,然后再试一次,或者在firewall中添加异常。

cqoc49vn

cqoc49vn5#

检查你的tomcat下载版本。如果你打开你解压的tomcat文件夹,你必须看到log文件夹。否则可能是你安装了apache-tomcat-src.tar.gz。如果你的文件路径显示src,它不会给予你一个日志文件。所以删除tomcat文件夹并下载apache-tomcat-8.tar.gz正确的文件。现在安装它。

8wigbo56

8wigbo566#

Apache tomcat8.0.27及更低版本在jdk 9中不工作,请将其更改为更低版本。截至2018年10月。更新版本的tomcat结果可能会更改。

wpcxdonn

wpcxdonn7#

For this question, I've seen some answers online that suggest it's because it's not executed with the root user's privileges. However, you will find that this doesn't work. It still shows r the following error:

Using CATALINA_BASE:   /home/nzwl2020/apache-tomcat-8.5.87
Using CATALINA_HOME:   /home/nzwl2020/apache-tomcat-8.5.87
Using CATALINA_TMPDIR: /home/nzwl2020/apache-tomcat-8.5.87/temp
Using JRE_HOME:        /usr/loacl/java
Using CLASSPATH:       /home/nzwl2020/apache-tomcat-8.5.87/bin/bootstrap.jar:/home/nzwl2020/apache-tomcat-8.5.87/bin/tomcat-juli.jar
Using CATALINA_OPTS:   
./catalina.sh: 1: eval: /usr/loacl/java/bin/java: not found

If at this point you print the JAVA_HOME variable and the PATH variable, you will see that this is not the same as what you set when you installed the JDK and Tomcat earlier.
Also, we find that the java command cannot be found.

java -version
找不到命令 “java”,但可以通过以下软件包安装它:
apt install openjdk-11-jre-headless  # version 11.0.18+10-0ubuntu1~22.04, or
apt install default-jre              # version 2:1.11-72build2
apt install openjdk-17-jre-headless  # version 17.0.6+10-0ubuntu1~22.04
apt install openjdk-18-jre-headless  # version 18.0.2+9-2~22.04
apt install openjdk-19-jre-headless  # version 19.0.2+7-0ubuntu3~22.04
apt install openjdk-8-jre-headless   # version 8u362-ga-0ubuntu1~22.04

That's because you used the su root command instead of the su - root command.
Compare the su and su - commands: su switches the user's access, but does not get the environment variable, so PATH is not brought in; su - is the full switching user, changing the working directory and getting environment variables, so you can find JAVA_HOME.
When we use the normal su command to switch from one user to another, the current directory remains the same as the previous user.
When we use the su - command to switch from one user to another, the current directory is changed to the target user's home directory.
The su command does not create a new user environment, but rather the su - command creates a completely new user environment.
Switch to superuser with su - root command, enter your user password (if you have one), go to the apache-tomcat-8.5.87/bin directory, and execute the startup.sh jscript file to start Tomcat. The following result will be displayed.

Using CATALINA_BASE:   /home/nzwl2020/apache-tomcat-8.5.87
Using CATALINA_HOME:   /home/nzwl2020/apache-tomcat-8.5.87
Using CATALINA_TMPDIR: /home/nzwl2020/apache-tomcat-8.5.87/temp
Using JRE_HOME:        /usr/local/java
Using CLASSPATH:       /home/nzwl2020/apache-tomcat-8.5.87/bin/bootstrap.jar:/home/nzwl2020/apache-tomcat-8.5.87/bin/tomcat-juli.jar
Using CATALINA_OPTS:   
Tomcat started.

Check if the Tomcat process is running.

ps -ef | grep java

root 9524 1084 11 21:49 pts/2 00:00:03 /usr/local/java/bin/java -Djava.util.logging.config.file=/home/nzwl2020/apache-tomcat-8.5.87/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /home/nzwl2020/apache-tomcat-8.5.87/bin/bootstrap.jar:/home/nzwl2020/apache-tomcat-8.5.87/bin/tomcat-juli.jar -Dcatalina.base=/home/nzwl2020/apache-tomcat-8.5.87 -Dcatalina.home=/home/nzwl2020/apache-tomcat-8.5.87 -Djava.io.tmpdir=/home/nzwl2020/apache-tomcat-8.5.87/temp org.apache.catalina.startup.Bootstrap start root 9558 9442 0 21:49 pts/2 00:00:00 grep --color=auto java

netstat -anp | grep 8080

tcp6 0 0 :::8080 :::* LISTEN 9524/java
Turn off the firewall.

ufw disable

Visit http://localhost:8080 in your browser (of course, your Tomcat's port may not be 8080).

相关问题