Sunday, December 2, 2012

Set-up Amazon EC2 instace[ubuntu] with Tomcat6 and MongoDB

Requirements

1. AWS Account .You may check it here
2. EC2 Instance. Check the online guide here

Enable SSH connection

1. Inside your Amazon EC2 Dashboard, go to Security Group


2. Define inbound connections to your instance.
SSH 
port range :22
HTTP
port range : 80
default Tomcat 
port range : 8080
Source : [IP]/32

be sure to apply the rule changes



3. Get Default Public DNS of your instance



Connect to instance via putty

Check this link for the detailed instructions to connect to your instance via putty

Install Tomcat

1. Connect to your instance via putty (check link above) . the default login for an ubuntu instance is ubuntu lol
2. Install tomcat.
   sudo apt-get install tomcat6 tomcat6-admin
3. Edit users
     sudo vi /etc/tomcat6/tomcat-users.xml
4. Restart tomcat
   sudo /etc/init.d/tomcat6 restart
Notes 
You may deploy your web-applications via SFTP to
/usr/share/tomcat6/webapps
5. Test your installation via browser
http://[PUBLIC DNS]:8080/

Install MongoDB

1. download mongoDB
 curl -O http://downloads.mongodb.org/linux/mongodb-linux-x86_64-2.2.2.tgz
2. extract tar file
tar -xzf mongodb-linux-x86_64-2.2.2.tgz
3. Start MongoDB
%MONGO_HOME%/mongod --fork --logpath ~/mongod.log  --dbpath /home/ubuntu/db
4. check if the process is running 
ps -ef|grep mongod
note: change the logpath and dbpath
more info : http://www.mongodb.org/display/DOCS/Amazon+EC2

Thats it :D