简体   繁体   English

Tomcat无法在Amazon EC2,Redhat实例上运行

[英]Tomcat not running on Amazon EC2, Redhat Instance

I'm a java application developer, and don't know much about linux configuration. 我是一名java应用程序开发人员,对linux配置知之甚少。

I'm trying to install Java and Tomcat to a fresh Redhat instance on Amazon EC2, and executed the below script. 我正在尝试将Java和Tomcat安装到Amazon EC2上的新Redhat实例上,并执行以下脚本。

mkdir /usr/local/java
cd /usr/local/java
curl http://download.oracle.com/otn-pub/java/jdk/7u2-b13/jdk-7u2-linux-i586.rpm > jdk.rpm
rpm -iv jdk.rpm

updatedb; locate javac | grep bin  # this step merely serves to verify the installation
/usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_02/bin/java 100
/usr/sbin/alternatives --install /usr/bin/jar jar /usr/java/jdk1.7.0_02/bin/jar 100
/usr/sbin/alternatives --install /usr/bin/javac javac /usr/java/jdk1.7.0_02/bin/javac 100
/usr/sbin/alternatives --config java
updatedb

mkdir /env
mkdir /env/tomcat
cd /env/tomcat
curl http://www.gtlib.gatech.edu/pub/apache/tomcat/tomcat-7/v7.0.23/bin/apache-tomcat-7.0.23.tar.gz > apache-tomcat-7.0.23.tar.gz
tar zxvf apache-tomcat-7.0.23.tar.gz
cd apache-tomcat-7.0.23
bin/startup.sh # 

At this point, http://ec2-23-20-24-96.compute-1.amazonaws.com:8080/ was expected to return Tomcat homepage, but it didn't :( 此时, http://ec2-23-20-24-96.compute-1.amazonaws.com:8080/有望返回Tomcat主页,但它没有:(

cd /etc/rc.d/init.d/
vi tomcat

I pasted the below content to the file: 我将以下内容粘贴到文件中:

#!/bin/sh
# Tomcat init script for Linux.
#
# chkconfig: 2345 96 14
# description: The Apache Tomcat servlet/JSP container.

JAVA_HOME=/usr/java/jdk1.7.0_02
CATALINA_HOME=/env/tomcat/apache-tomcat-7.0.23
export JAVA_HOME CATALINA_HOME

exec $CATALINA_HOME/bin/catalina.sh $*

Then executed: 然后执行:

chmod 755 /etc/rc.d/init.d/tomcat
chkconfig --level 2345 tomcat on

export JAVA_HOME=/usr/java/jdk1.7.0_02
export PATH=$PATH:/usr/java/jdk1.7.0_02
export CATALINA_HOME=/env/tomcat/apache-tomcat-7.0.23

/env/tomcat/apache-tomcat-7.0.23/bin/shutdown.sh
/env/tomcat/apache-tomcat-7.0.23/bin/startup.sh

Nowhere did I get any error, but I also couldn't get the Tomcat homepage to display. 我没有收到任何错误,但我也无法显示Tomcat主页。 Can you guide where where I went wrong. 你能指导我哪里出错吗?

Thanks 谢谢
James 詹姆士

EDIT: 编辑:

Tomcat log (on stopping and starting server) Tomcat日志(停止和启动服务器时)

Jan 18, 2012 2:06:48 AM org.apache.catalina.core.StandardServer await
INFO: A valid shutdown command was received via the shutdown port. Stopping the Server instance.
Jan 18, 2012 2:06:48 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-8080"]
Jan 18, 2012 2:06:48 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
Jan 18, 2012 2:06:48 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Jan 18, 2012 2:06:48 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-bio-8080"]
Jan 18, 2012 2:06:48 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["ajp-bio-8009"]
Jan 18, 2012 2:06:48 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-bio-8080"]
Jan 18, 2012 2:06:48 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-bio-8009"]
Jan 18, 2012 2:08:46 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/i386:/lib:/usr/lib
Jan 18, 2012 2:08:46 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jan 18, 2012 2:08:46 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jan 18, 2012 2:08:46 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 530 ms
Jan 18, 2012 2:08:46 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jan 18, 2012 2:08:46 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.23
Jan 18, 2012 2:08:46 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /env/tomcat/apache-tomcat-7.0.23/webapps/examples
Jan 18, 2012 2:08:47 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /env/tomcat/apache-tomcat-7.0.23/webapps/host-manager
Jan 18, 2012 2:08:47 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /env/tomcat/apache-tomcat-7.0.23/webapps/manager
Jan 18, 2012 2:08:47 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /env/tomcat/apache-tomcat-7.0.23/webapps/docs
Jan 18, 2012 2:08:47 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /env/tomcat/apache-tomcat-7.0.23/webapps/ROOT
Jan 18, 2012 2:08:47 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jan 18, 2012 2:08:47 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jan 18, 2012 2:08:47 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 583 ms

EDIT2: EDIT2:

My problem looks similar to the one on https://forums.aws.amazon.com/thread.jspa?threadID=59937 , but that provides no solution. 我的问题看起来类似于https://forums.aws.amazon.com/thread.jspa?threadID=59937上的问题 ,但这没有提供任何解决方案。

I performed a wget, and I received a proper index.html with Tomcat homepage html. 我执行了一个wget,然后我收到了一个带有Tomcat主页html的正确index.html。
wget http://ec2-23-20-24-96.compute-1.amazonaws.com:8080 wget http://ec2-23-20-24-96.compute-1.amazonaws.com:8080

I have two security groups - default and quick-start-1, and I've added ports 80 and 8080 to the list. 我有两个安全组 - 默认和快速启动-1,我已经将端口80和8080添加到列表中。

Solved it with help from AWS Support: 在AWS Support的帮助下解决了这个问题:

Hello 你好

It initially looks like iptables is running on your instance, my checks show filtered ports, you will need to add a rule to allow port 8080, or disable the firewall on the instance itself. 它最初看起来像iptables在你的实例上运行,我的检查显示过滤端口,你需要添加规则以允许端口8080,或者禁用实例本身的防火墙。

You can verify this by running as root " service iptables stop " and then see if you can connect on port 8080. 您可以通过以root“ service iptables stop ”运行来验证这一点,然后查看是否可以在端口8080上连接。

Kind Regards 亲切的问候
AndyC AndyC

Link: https://forums.aws.amazon.com/thread.jspa?messageID=312167&#312167 链接: https//forums.aws.amazon.com/thread.jspa?messageID = 312167&#313127

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM