Installing Java JDK on Amazon Linux AMI
Most likely you already have Open JDK installed on you EC2 instance. You will have replace OpenJDK with Oracle JDK. Here is how you do it.
Perform all the operations below as root.Get the latest Oracle (Sun) JDK rmp binary from the Oracle website and copy it to the EC2 instance.
# make it exec chmod +x jdk-6u34-linux-x64-rpm.bin # Install Java sudo ./jdk-6u34-linux-x64-rpm.bin # Check if the default java version is set to sun jdk # Normally it says OpenJDK java -version # Create another alternative for Java for Sun JDK sudo /usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_34/bin/java 20000 # Set the SUN JDK as the default java sudo /usr/sbin/alternatives --config java # Verify if change in SDK was done. java -version
Installing Tomcat on Amazon Linux AMI
# Check if tomcat is already installed yum info tomcat6 # To install tomcat6, run the following command yum install tomcat6 # Start Tomcat as follows service tomcat6 start
Tomcat has now been installe in /usr/share/tomcat6/
# To check that Tomcat has indeed started and is listening on port 8080: fuser -v -n tcp 8080 #To have Tomcat start automatically on instance reboot chkconfig --level 345 tomcat6 on
Tomcat by default runs on port 8080. Traffic can be redirected from port 80 to 8080 by running the following commands:
/sbin/iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080 /sbin/service iptables save