Tomcat not working on Amazon EC2, Redhat Instance

I am a Java application developer and know little about Linux configuration.

I am trying to install Java and Tomcat in a new instance of Redhat on Amazon EC2 and execute the below script.

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, it is expected that http://ec2-23-20-24-96.compute-1.amazonaws.com:8080/ will return the Tomcat homepage, but this did not happen :(

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

I pasted the contents below into a 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 runs:

 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 errors, but I also could not get the Tomcat main page. Can you indicate where I was wrong.

thanks
James

EDIT:

Tomcat Log (on the Stop and Start Server)

 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:

My problem is similar to the problem https://forums.aws.amazon.com/thread.jspa?threadID=59937 , but this does not provide a solution.

I executed wget and I got the correct index.html with the Tomcat html main page.
wget http://ec2-23-20-24-96.compute-1.amazonaws.com:8080

I have two security groups - default and quick start-1, and I added ports 80 and 8080 to the list.

+4
source share
1 answer

Solved it using AWS support:

Hello

At first it looks like iptables works on your instance, my checks show filtered ports, you need to add a rule to allow port 8080, or disable the firewall in the instance itself.

You can verify this by running the root command “ service iptables stop ”, and then see if you can connect to port 8080.

Regards, AndyC

Link: https://forums.aws.amazon.com/thread.jspa?messageID=312167񌍧

+5
source

Source: https://habr.com/ru/post/1391589/


All Articles