Amazon EC2 module is a virtual server in cloud. It's a IaaS (Infrastructure as a service) when you have your own machine (virtual) with an operating system and you can deploy your stuff there. We have already discussed setting up an EC2 instance and connecting to it. If you do not recollect please refer -
Setup Tomcat on an Amazon EC2 instance to deploy a wep app
Apache Tomcat, often referred to as Tomcat, is an open-source web server developed by the Apache Software Foundation (ASF). Tomcat implements several Java EE specifications including Java Servlet, JavaServer Pages (JSP), Java EL, and WebSocket, and provides a "pure Java" HTTP web server environment in which Java code can run.
There are two ways you can setup tomcat on your machine (EC2 instance) in this case. Either
- install it through apt-get
- Download the binary distribution from their official site and use
- sudo apt-get update
Next install tomcat7 -
- sudo apt-get install tomcat7
Post installation you can see the default configuration file located at -
- less /etc/default/tomcat7
You can change the configuration parameters here if you wish.
To start,stop and see current tomcat status you can use following commands -
- sudo service tomcat7 start
- sudo service tomcat7 stop
- sudo service tomcat7 status
Next you can deploy your webapps at /var/lib/tomcat7/webapps
- CATALINA_HOME : /usr/share/tomcat7
- CATALINA_BASE : /var/lib/tomcat7
Now your tomcat installation is done. Tomcat by default runs on port 8080 that you need to open externally (for inbound traffic). Go to Security Groups and add a custom TCP rule to open port 8080 externally -
Add the rule and save it. You should not be able to access your tomcat. If it shows you Its up! page you are all set!
Once deployed you can hit following URL and see if it works. If it does not you need to check catalina.out logs for any deployment issues.
You should see a page something like above.