Saturday 8 September 2012

Amazon EC2 Basics (Part 1)

(Before we begin, note that the instructions for installing Tomcat 7 is for the version that is included with Amazon's repository. For instructions for installing the official and full Apache Tomcat version, please read Part 1.2 instead.)

Here is a short description of how to get started with an EC2 Project for absolute beginners. We'll also be exploring the following stuff along the way- Tomcat 7, Apache 2, mod_proxy.
  1. Go to your Amazon EC2 console (online) and start up a new instance.
  2. Follow the steps from there, its pretty straightforward. The main step you need to take care of is when setting up the security group.
    • You'll want to create a rule for ICMP (from the drop down), select "All". This enables ping.
    • You'll want to create a rule for TCP for port 22 so that you can ssh in
    • You'll want to create a rule for TCP for port 8080 for http
  3. When you're done, you can start the instance from the online console itself.
  4. Next, right click the instance and click "Connect". You'll be able to see the ssh command which you can execute via your terminal.
  5. Run a bunch of commands
    • sudo yum update (to get the latest patches)
    • sudo yum install java-1.6.0-openjdk-devel (to get the JDK; you only have the JRE right now; if you get the full JDK, you can debug in tomcat)
    • sudo yum install tomcat7 (to install tomcat 7; located in /var/lib; conf is located in /etc/tomcat7)
    • sudo service tomcat7 start (to start tomcat)
    • sudo yum install tomcat7-webapps tomcat7-docs-webapp tomcat7-admin-webapps (to get the webapps, which aren't downloaded with the tomcat package)
  6. Now, connect to your instance on port 8080 e.g.,

  7. From here, you'd probably want to navigate to the manager app, but probably won't be able to because access to the manager app is restricted by default.
    • vim /etc/tomcat7/tomcat-users.xml (vim is my text editor of choice, you can choose any text editor, really; if you are denied permission to change the tomcat-users.xml file, you'll need to change permissions for this file using the chmod command)
    • insert the following into the tomcat-users.xml file: <role rolename="manager-gui" />
    • also insert: <user username="tomcat" password="pwd" roles="manager-gui" />
    • now you need to restart tomcat (sudo service tomcat7 restart)
    • connect to your instance on port 8080 again, click on manager and input the username and password
  8. You're all set! Just head on over to the tomcat manager and deploy your war files!
(This post is based on this article.)

No comments:

Post a Comment