SlideShare a Scribd company logo
Deploying Rails app on Amazon EC2 By: Manik Juneja Akhil Bansal
Introduction Manik Juneja [email_address] http://fromdelhi.com Akhil Bansal [email_address] http://webonrails.com
Intended audience We assume that you are aware of: Amazon Simple Storage System(S3) Basic Ruby and Rails  Deployment tool “Capistrano” Rails deployment with Apache and Mongrel Clusters
What is Amazon EC2? EC2 stands for Elastic Compute Cloud A Beta web service from Amazon Provides resizable compute capacity in the cloud Makes on-demand web computing easier
What Amazon Gives? Hardware CPU capacity of 1.0-1.2 GHz 2007 Opteron Instances with 1.7, 7.5 and 15 GB memory. Internet & Intranet  Power Public Amazon Machine Images(AMIs)
No Backup and Restore Services But
Deploying Rails app on EC2
Deploying Rails app on EC2 Run your instance and: Install Ruby and Rubygems  Install Rails and other required gems Install Webserver Install DBMS and create DB Write Capistrano Script
OR
Use a rubyforge project “ec2onrails”
Deploying Rails app on EC2 We'll use ruby gem “EC2 on Rails” Developed by a Canadian developer Paul Dowman http://pauldowman.com/ EC2 on Rails's AMI
Features of the EC2onrails AMI: Ubuntu 7.10 “Gutsy”  MySQL 5 Ruby 1.8.6 Ruby on Rails 1.2.5 Automatic backup of MySQL database to S3. Amazon AMI tools installed 32-bit and 64-bit images available
Lets Deploy  gem install ec2onrails Put  Capfile  in the RAILS_ROOT Put  deploy.rb  and  s3.yml  in the config  export  JAVA_HOME= <PATH> Signup for S3 and Amazon EC2 mkdir  /home/akhil/.ec2 Put X.509 certificate and private key in .ec2
Cont... Download the Amazon EC2 Command-Line Tools export  EC2_HOME= <path-to-tools>   export  PATH=$PATH:$EC2_HOME/bin export  EC2_PRIVATE_KEY=~/.ec2/ private_key export  EC2_CERT=~/.ec2/ certificate
Cont... Generate a Keypair:  ec2-add-keypair gsg-keypair The private key returned needs to be saved in a local file so that you can use it later
Cont... Running an Instance: ec2-run-instances ami-86c025ef -k gsg-keypair RESERVATION  r-64f61f0d  110620076136  default INSTANCE  i-b1b740d8   ami-86c025ef  pending gsg-keypair  0  m1.small  2007-12-05T06:15:38+0000
Cont... ec2-describe-instances   i-b1b740d8 RESERVATION  r-64f61f0d  110620076136  default INSTANCE  i-b1b740d8  ami-86c025ef  ec2-67-202-1-178.z-2.compute-1.amazonaws.com   domU-12-31-35-00-49-A2.z-2.compute-1.internal  running gsg-keypair  0  m1.small  2007-12-05T06:15:38+0000
Cont... Authorizing Network Access to Your Instances ec2-authorize default -p 22 ec2-authorize default -p 80
Cont... Connecting to your Instance ssh -i id_rsa-gsg-keypair  [email_address] passwd admin passwd app
Cont... Modify s3.yml Modify deploy.rb cap ec2onrails:setup cap deploy:migration s
Cont... Other capistrano tasks ec2onrails:db:archive ec2onrails:db:restore ec2onrails:db:create ec2onrails:db:drop ec2onrails:db:recreate ec2onrails:db:set_root_password ec2onrails:ami_ids - Shows the AMI id’s of the images that match the current version of the gem. ec2onrails:setup - This is a convenience task to get a new instance completely set up in one step, everything except deploying the app. ec2onrails:restore_db_and_deploy - Another convenience task to recreate the db, restore data to it from an s3 bucket and deploy the app, useful to set up a staging server.
Public IP Your Instances wget  http://169.254.169.254/latest/meta-data/public-ipv4  from your Instance
Terminating Your Instances ec2-terminate-instances i-b1b740d8 RESERVATION  r-64f61f0d  110620076136  default INSTANCE  i-b1b740d8  ami-86c025ef  ec2-67-202-1-178.z-2.compute-1.amazonaws.com  domU-12-31-35-00-49-A2.z-2.compute-1.internal  shutting-down   gsg-keypair  0  m1.small  2007-12-05T06:15:38+0000
Check status of instances ec2-describe-instances RESERVATION  r-64f61f0d  110620076136  default INSTANCE  i-b1b740d8  ami-86c025ef  terminated   gsg-keypair  0  m1.small  2007-12-05T06:15:38+0000
Run and Manage Instances online We know this one service which let us mange instances online: RightScale.com
Benefits Ability to Start, terminate, and monitor instances, using the web service APIs. Free Data transferred within the Amazon EC2 environment, or between Amazon EC2 and Amazon S3 Pay for the instance-hours and bandwidth that you actually consume.
Points to consider: Data loss when instance is terminated Instance gets a new public IP when started again Need to use third party Dynamic DNS service, like “easydns.com”.
Thanks

More Related Content

PDF
docker-machine, docker-compose, docker-swarm 覚書
PDF
k8s-on-azure
PDF
Ansible container
PDF
EKS에서 Opentelemetry로 코드실행 모니터링하기 - 신재현 (인덴트코퍼레이션) :: AWS Community Day Online...
PDF
How To Create EC2 instance Linux Server
PDF
전 세계 팬들이 모일 수 있는 플랫폼 만들기 - 강진우 (beNX) :: AWS Community Day 2020
PPTX
DotNet Conf Valencia 2019 - Building cloud native apps with .NRT core 3.0 and...
DOCX
Install Kubernetes Cluster on Azure Platform using kubespray
docker-machine, docker-compose, docker-swarm 覚書
k8s-on-azure
Ansible container
EKS에서 Opentelemetry로 코드실행 모니터링하기 - 신재현 (인덴트코퍼레이션) :: AWS Community Day Online...
How To Create EC2 instance Linux Server
전 세계 팬들이 모일 수 있는 플랫폼 만들기 - 강진우 (beNX) :: AWS Community Day 2020
DotNet Conf Valencia 2019 - Building cloud native apps with .NRT core 3.0 and...
Install Kubernetes Cluster on Azure Platform using kubespray

What's hot (19)

PDF
Ansible-for-openstack
PPTX
Deploying your web application with AWS ElasticBeanstalk
PPTX
Cyansible
PDF
Deep drive into Nova
DOCX
How to configure amazon ec2 load balancer
PDF
20211120 Automating EC2 operations / EC2運用の自動化
PPTX
Basics of Ansible - Sahil Davawala
PDF
Dockerized .Net Core based app services in azure K8s
ODP
AWS ground zero; EC2 & S3 hands-on
PDF
Ansible 2.2
PPTX
London Community Summit - Habitat 2016
PDF
How to launch an aws ec2 instance
PDF
Nikita Tuk: Handling background processes in iOS: problems & solutions
PPTX
Setting up MySQL Replication Cluster in Kubernetes
PDF
Spring Boot - Microservice Metrics Monitoring
PDF
Heat up your stack
PPTX
Fun with Fargate and Kubernetes on AWS
PDF
Elastic ip
PDF
DevOps with Ansible
Ansible-for-openstack
Deploying your web application with AWS ElasticBeanstalk
Cyansible
Deep drive into Nova
How to configure amazon ec2 load balancer
20211120 Automating EC2 operations / EC2運用の自動化
Basics of Ansible - Sahil Davawala
Dockerized .Net Core based app services in azure K8s
AWS ground zero; EC2 & S3 hands-on
Ansible 2.2
London Community Summit - Habitat 2016
How to launch an aws ec2 instance
Nikita Tuk: Handling background processes in iOS: problems & solutions
Setting up MySQL Replication Cluster in Kubernetes
Spring Boot - Microservice Metrics Monitoring
Heat up your stack
Fun with Fargate and Kubernetes on AWS
Elastic ip
DevOps with Ansible
Ad

Viewers also liked (8)

PPS
calendario play boy 2006
PPS
ilusion optica
PDF
Hombre de verdad_se_nace
PDF
Using Amazon Simple Db With Rails
ODP
Apache Rewrite Rules
PPT
PPT
Making Your Resume Great
PPTX
Cte 2015 16 6 sesion abril
calendario play boy 2006
ilusion optica
Hombre de verdad_se_nace
Using Amazon Simple Db With Rails
Apache Rewrite Rules
Making Your Resume Great
Cte 2015 16 6 sesion abril
Ad

Similar to Deploying Rails App On Ec2 (20)

ODP
Amazon EC2 + Rails
PDF
Hosting Ruby Web Apps
PPT
Hosting a Rails App
PPTX
Capistrano 3 Deployment
PPT
Capistrano Deployment By Nyros Developer
PDF
Large-scaled Deploy Over 100 Servers in 3 Minutes
PPTX
Getting Started with Capistrano
PDF
Advanced technic for OS upgrading in 3 minutes
PPTX
Deep Dive on Amazon Elastic Container Service (ECS) I AWS Dev Day 2018
PDF
PPTX
An intro to Docker, Terraform, and Amazon ECS
PPT
Capistrano
PDF
Deploying Rails on EC2 using Rubber (Slides Only)
DOCX
Guide - Migrating from Heroku to AWS using CloudFormation
PDF
Capistrano deploy Magento project in an efficient way
PPTX
An Engineers Guide to the AWS Ruby SDK
PDF
Is the order code deploy?
PDF
A 60-mn tour of AWS compute (March 2016)
PDF
Capistrano
PPT
The Future is Now: Leveraging the Cloud with Ruby
Amazon EC2 + Rails
Hosting Ruby Web Apps
Hosting a Rails App
Capistrano 3 Deployment
Capistrano Deployment By Nyros Developer
Large-scaled Deploy Over 100 Servers in 3 Minutes
Getting Started with Capistrano
Advanced technic for OS upgrading in 3 minutes
Deep Dive on Amazon Elastic Container Service (ECS) I AWS Dev Day 2018
An intro to Docker, Terraform, and Amazon ECS
Capistrano
Deploying Rails on EC2 using Rubber (Slides Only)
Guide - Migrating from Heroku to AWS using CloudFormation
Capistrano deploy Magento project in an efficient way
An Engineers Guide to the AWS Ruby SDK
Is the order code deploy?
A 60-mn tour of AWS compute (March 2016)
Capistrano
The Future is Now: Leveraging the Cloud with Ruby

Recently uploaded (20)

PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
cuic standard and advanced reporting.pdf
PPTX
Big Data Technologies - Introduction.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Spectroscopy.pptx food analysis technology
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Approach and Philosophy of On baking technology
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Electronic commerce courselecture one. Pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Review of recent advances in non-invasive hemoglobin estimation
MIND Revenue Release Quarter 2 2025 Press Release
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
cuic standard and advanced reporting.pdf
Big Data Technologies - Introduction.pptx
The AUB Centre for AI in Media Proposal.docx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Spectroscopy.pptx food analysis technology
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Approach and Philosophy of On baking technology
Network Security Unit 5.pdf for BCA BBA.
NewMind AI Weekly Chronicles - August'25 Week I
Electronic commerce courselecture one. Pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Understanding_Digital_Forensics_Presentation.pptx
20250228 LYD VKU AI Blended-Learning.pptx

Deploying Rails App On Ec2

  • 1. Deploying Rails app on Amazon EC2 By: Manik Juneja Akhil Bansal
  • 2. Introduction Manik Juneja [email_address] http://fromdelhi.com Akhil Bansal [email_address] http://webonrails.com
  • 3. Intended audience We assume that you are aware of: Amazon Simple Storage System(S3) Basic Ruby and Rails Deployment tool “Capistrano” Rails deployment with Apache and Mongrel Clusters
  • 4. What is Amazon EC2? EC2 stands for Elastic Compute Cloud A Beta web service from Amazon Provides resizable compute capacity in the cloud Makes on-demand web computing easier
  • 5. What Amazon Gives? Hardware CPU capacity of 1.0-1.2 GHz 2007 Opteron Instances with 1.7, 7.5 and 15 GB memory. Internet & Intranet Power Public Amazon Machine Images(AMIs)
  • 6. No Backup and Restore Services But
  • 8. Deploying Rails app on EC2 Run your instance and: Install Ruby and Rubygems Install Rails and other required gems Install Webserver Install DBMS and create DB Write Capistrano Script
  • 9. OR
  • 10. Use a rubyforge project “ec2onrails”
  • 11. Deploying Rails app on EC2 We'll use ruby gem “EC2 on Rails” Developed by a Canadian developer Paul Dowman http://pauldowman.com/ EC2 on Rails's AMI
  • 12. Features of the EC2onrails AMI: Ubuntu 7.10 “Gutsy” MySQL 5 Ruby 1.8.6 Ruby on Rails 1.2.5 Automatic backup of MySQL database to S3. Amazon AMI tools installed 32-bit and 64-bit images available
  • 13. Lets Deploy gem install ec2onrails Put Capfile in the RAILS_ROOT Put deploy.rb and s3.yml in the config export JAVA_HOME= <PATH> Signup for S3 and Amazon EC2 mkdir /home/akhil/.ec2 Put X.509 certificate and private key in .ec2
  • 14. Cont... Download the Amazon EC2 Command-Line Tools export EC2_HOME= <path-to-tools> export PATH=$PATH:$EC2_HOME/bin export EC2_PRIVATE_KEY=~/.ec2/ private_key export EC2_CERT=~/.ec2/ certificate
  • 15. Cont... Generate a Keypair: ec2-add-keypair gsg-keypair The private key returned needs to be saved in a local file so that you can use it later
  • 16. Cont... Running an Instance: ec2-run-instances ami-86c025ef -k gsg-keypair RESERVATION r-64f61f0d 110620076136 default INSTANCE i-b1b740d8 ami-86c025ef pending gsg-keypair 0 m1.small 2007-12-05T06:15:38+0000
  • 17. Cont... ec2-describe-instances i-b1b740d8 RESERVATION r-64f61f0d 110620076136 default INSTANCE i-b1b740d8 ami-86c025ef ec2-67-202-1-178.z-2.compute-1.amazonaws.com domU-12-31-35-00-49-A2.z-2.compute-1.internal running gsg-keypair 0 m1.small 2007-12-05T06:15:38+0000
  • 18. Cont... Authorizing Network Access to Your Instances ec2-authorize default -p 22 ec2-authorize default -p 80
  • 19. Cont... Connecting to your Instance ssh -i id_rsa-gsg-keypair [email_address] passwd admin passwd app
  • 20. Cont... Modify s3.yml Modify deploy.rb cap ec2onrails:setup cap deploy:migration s
  • 21. Cont... Other capistrano tasks ec2onrails:db:archive ec2onrails:db:restore ec2onrails:db:create ec2onrails:db:drop ec2onrails:db:recreate ec2onrails:db:set_root_password ec2onrails:ami_ids - Shows the AMI id’s of the images that match the current version of the gem. ec2onrails:setup - This is a convenience task to get a new instance completely set up in one step, everything except deploying the app. ec2onrails:restore_db_and_deploy - Another convenience task to recreate the db, restore data to it from an s3 bucket and deploy the app, useful to set up a staging server.
  • 22. Public IP Your Instances wget http://169.254.169.254/latest/meta-data/public-ipv4 from your Instance
  • 23. Terminating Your Instances ec2-terminate-instances i-b1b740d8 RESERVATION r-64f61f0d 110620076136 default INSTANCE i-b1b740d8 ami-86c025ef ec2-67-202-1-178.z-2.compute-1.amazonaws.com domU-12-31-35-00-49-A2.z-2.compute-1.internal shutting-down gsg-keypair 0 m1.small 2007-12-05T06:15:38+0000
  • 24. Check status of instances ec2-describe-instances RESERVATION r-64f61f0d 110620076136 default INSTANCE i-b1b740d8 ami-86c025ef terminated gsg-keypair 0 m1.small 2007-12-05T06:15:38+0000
  • 25. Run and Manage Instances online We know this one service which let us mange instances online: RightScale.com
  • 26. Benefits Ability to Start, terminate, and monitor instances, using the web service APIs. Free Data transferred within the Amazon EC2 environment, or between Amazon EC2 and Amazon S3 Pay for the instance-hours and bandwidth that you actually consume.
  • 27. Points to consider: Data loss when instance is terminated Instance gets a new public IP when started again Need to use third party Dynamic DNS service, like “easydns.com”.