SlideShare a Scribd company logo
06.04.2013
Hosting A Rails App
Why am I presenting this?
• Level Seven
• Support a bunch of
production rails apps
• Biggest has between 20-
30 boxes of various types
• Still learning
We’re Hiring!
• Ya i know, who isn’t?
• Full time ruby on rails
• Happy to help someone pick
up their first real rails gig
• Also we like contractors and
independents
Hosting Options
• Heroku
• Great for new/young
projects
• Easy to manage
• Gets expensive quick
• Pretty inflexible, very little
control
• AWS
• More complicated setup
• Can also get expensive but
easier to control (YMMV)
• Awesome set of tools that all
play well together
• You need to know or be a
sysadmin
Free Micro Instance
• Everything in this presentation you can try out for yourself for free
• Amazon Free Tier
• Free Micro EC2 Instance, 1 static IP, 30 gig EBS space and a load
balancer plus a bunch of other stuff
• http://aws.amazon.com/free/
• Any code / scripts will be on github and these slides will be on
slideshare. I’ll tweet their location after the talk.
• I have a bunch of hidden slides that screenshot the amazon setup
process too
Step 0: Assumptions & Spinup
• We’ll be using an Ubuntu 12.01 instance. It’s a default in AWS.
• This guide is really Amazon stack heavy. I’ve worked with it, heroku
and rackspace (a little) so if you have questions I’m happy to try and
help.
• You should setup an elastic IP on your server right away for easy of
use, but I’ll talk about it later on.
Step 0: Assumptions & Spinup
• First spinup a new instance on EC2 using Ubuntu 13.04
• Ideally add a 2nd EBS volume with additional storage space
• Associate an Elastic IP with that box
• Setup a new Host record in ~/.ssh/config for the new server
Host ClerbDemo
HostName 107.20.194.126
IdentityFile ~/.ssh/AWSJosh.pem
ForwardAgent yes
• That last line will be important later
Step 1 - Dependencies
• Install the various libraries and dev tools you’ll need to install the rest
of the server
> sudo apt-get -y update #update apt to the latest packages
> sudo apt-get -y install build-essential zlib1g-dev libssl-dev
libreadline-dev libyaml-dev libcurl4-openssl-dev curl git-core python-
software-properties libxslt-dev libxml2-dev imagemagick pdftk
openjdk-7-jre-headless
• Install NodeJS for Asset Pipeline
> sudo apt-add-repository -y ppa:chris-lea/node.js
> sudo apt-get -y update
> sudo apt-get -y install nodejs
Step 1 - Dependencies
• Make your life better by disabling rdoc and ri installation for gems
> sudo echo “gem: --no-ri --no-rdoc” >> ~/.gemrc
> echo “gem: --no-ri --no-rdoc” >> ~/.gemrc
• Set your timezone (optional, maybe you want UTC)
>sudo dpkg-reconfigure tzdata #We use America/New York
Step 2 - Ruby
• 2 Ways to install, from source or via a system-wide RVM install
• RVM is really only useful if you plan on having multiple rubies
• Passenger 4 supports this and may result in me changing my
defaults pretty soon
• For now we’ll go with source
> wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz
> tar -xzvf ruby-2.0.0-p0.tar.gz
> cd ruby-2.0.0-p0
> ./configure
> make
> sudo make install
• dd
Step 3 - Web Server
• Lots of choices. Apache or Nginx w/ Passenger, Thin, Unicorn, etc.
• We’ll go with Apache w/ Passenger
• I REALLY like nginx but I haven’t used it enough yet
> sudo apt-get install apache2 apache2-mpm-prefork apache2-
prefork-dev
> sudo gem install passenger
> sudo passenger-install-apache2-module
# Follow instructions on screen
Step 3 - Web Server
• Setup the modules you’ll need
> sudo a2enmod ssl
> sudo a2enmod rewrite
> sudo a2enmod headers
> sudo a2enmod expires
> sudo a2enmod passenger
• We’ll need a virtual host for the site but we’ll do that later once we
have the code out there for the first time
• I like to setup the folder paths now though
> sudo mkdir /srv/www
> sudo chown ubuntu /srv/www
> sudo chgrp ubuntu /srv/www
Step 4 - Database
• Tons of options, popular ones include Postgres, MySQL for RDBMS
or MongoDB as NoSQL Alternative
• If you like MySQL you could use Amazon’s RDS Service
• We’ll go with PSQL for now
> sudo touch /etc/apt/sources.list.d/pgdg.list
> sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/
precise-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
>wget --quiet -O -
http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key
add -
> sudo apt-get -y update
> sudo apt-get -y install postgresql-9.2
• If your using a different DB and App server you have to modify the
postgres config to allow remote connections
Step 5 - DNS & IP Addresses
• For AWS your server will need an elastic IP
• You’ll need to setup that address in DNS, lots of options here:
• I recommend either Amazon’s Route 53 or DNSimple
• Both have great APIs, allow a lot of flexibility and aren’t Godaddy
• Setup an A Record to point to the IP address you got from amazon
Deployment
• Most rails apps on custom servers use capistrano
• https://help.github.com/articles/deploying-with-capistrano
• In short add capistano to your gemfile, bundle install, then:
> capify .
• Update the config/deploy.rb with your server info and path you want
the code
Deployment
• cap deploy:setup to create folder structure
• cap deploy:check to verify
• At this point you should make sure you database.yml file is on the
server in the proper place
• cap deploy
• cap deploy:migrations to deploy and run all migrations
Deployment
• You need a custom cap task for running asset pipeline generation
• You can support multiple environments using
capistrano/ext/multistage
• I like to build a cap task to copy the real db config into my project
post-deploy and not store production un/pw info in git
Stuff I Forgot Earlier
• You need to create a vhost in /etc/apache2/sites-available
• Also make sure your security group allows traffic on port 80
Stuff I didn’t cover
• Failover including load balancing
• Caching solutions like Varnish or advanced nginx caching
• Proxy server configurations
• Database replication or failover
• Backup
• Lots of other stuff...
References
• My Demo App
• https://github.com/JoshReedSchramm/HostingRailsDemoApp
• The Server Setup Script
• https://github.com/JoshReedSchramm/HostingRailsDemoApp/blob
/master/doc/setupscript.txt
• These Slides
• Some crazy slideshare url
Questions & Contact
• @JoshReedSchramm
• josh.schramm@gmail.com
or
josh.schramm@lvlsvn.com
Ad

More Related Content

What's hot (20)

Monitor-Driven Development Using Ansible
Monitor-Driven Development Using AnsibleMonitor-Driven Development Using Ansible
Monitor-Driven Development Using Ansible
Itamar Hassin
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
Suresh Kumar
 
Local Dev on Virtual Machines - Vagrant, VirtualBox and Ansible
Local Dev on Virtual Machines - Vagrant, VirtualBox and AnsibleLocal Dev on Virtual Machines - Vagrant, VirtualBox and Ansible
Local Dev on Virtual Machines - Vagrant, VirtualBox and Ansible
Jeff Geerling
 
Mitchell Hashimoto, HashiCorp
Mitchell Hashimoto, HashiCorpMitchell Hashimoto, HashiCorp
Mitchell Hashimoto, HashiCorp
Ontico
 
Automating aws infrastructure and code deployments using Ansible @WebEngage
Automating aws infrastructure and code deployments using Ansible @WebEngageAutomating aws infrastructure and code deployments using Ansible @WebEngage
Automating aws infrastructure and code deployments using Ansible @WebEngage
Vishal Uderani
 
Ansible Intro - June 2015 / Ansible Barcelona User Group
Ansible Intro - June 2015 / Ansible Barcelona User GroupAnsible Intro - June 2015 / Ansible Barcelona User Group
Ansible Intro - June 2015 / Ansible Barcelona User Group
Orestes Carracedo
 
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014
Miguel Zuniga
 
Forget MAMP and WAMP, Use Virtual Box to Have a Real Ubuntu Server
Forget MAMP and WAMP, Use Virtual Box to Have a Real Ubuntu ServerForget MAMP and WAMP, Use Virtual Box to Have a Real Ubuntu Server
Forget MAMP and WAMP, Use Virtual Box to Have a Real Ubuntu Server
aaroncouch
 
Automation in the Small: Code to Cloud
Automation in the Small: Code to CloudAutomation in the Small: Code to Cloud
Automation in the Small: Code to Cloud
Jay Barker
 
Ansible + WordPress - WordCamp Toronto 2016
Ansible + WordPress - WordCamp Toronto 2016Ansible + WordPress - WordCamp Toronto 2016
Ansible + WordPress - WordCamp Toronto 2016
Alan Lok
 
Ansible Case Studies
Ansible Case StudiesAnsible Case Studies
Ansible Case Studies
Greg DeKoenigsberg
 
Automated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. AnsibleAutomated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. Ansible
Alberto Molina Coballes
 
Fake IT, until you make IT
Fake IT, until you make ITFake IT, until you make IT
Fake IT, until you make IT
Bas Meijer
 
Automating the Cloud with Terraform, and Ansible
Automating the Cloud with Terraform, and AnsibleAutomating the Cloud with Terraform, and Ansible
Automating the Cloud with Terraform, and Ansible
Brian Hogan
 
Using Aws As A Game Server (AWS UG Bandung)
Using Aws As A Game Server (AWS UG Bandung)Using Aws As A Game Server (AWS UG Bandung)
Using Aws As A Game Server (AWS UG Bandung)
Aswin Juari
 
Go Faster with Ansible (PHP meetup)
Go Faster with Ansible (PHP meetup)Go Faster with Ansible (PHP meetup)
Go Faster with Ansible (PHP meetup)
Richard Donkin
 
Network Automation with Ansible
Network Automation with AnsibleNetwork Automation with Ansible
Network Automation with Ansible
Anas
 
Ansible - A 'crowd' introduction
Ansible - A 'crowd' introductionAnsible - A 'crowd' introduction
Ansible - A 'crowd' introduction
Manuel de la Peña Peña
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
Dharmit Shah
 
DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!
Jeff Geerling
 
Monitor-Driven Development Using Ansible
Monitor-Driven Development Using AnsibleMonitor-Driven Development Using Ansible
Monitor-Driven Development Using Ansible
Itamar Hassin
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
Suresh Kumar
 
Local Dev on Virtual Machines - Vagrant, VirtualBox and Ansible
Local Dev on Virtual Machines - Vagrant, VirtualBox and AnsibleLocal Dev on Virtual Machines - Vagrant, VirtualBox and Ansible
Local Dev on Virtual Machines - Vagrant, VirtualBox and Ansible
Jeff Geerling
 
Mitchell Hashimoto, HashiCorp
Mitchell Hashimoto, HashiCorpMitchell Hashimoto, HashiCorp
Mitchell Hashimoto, HashiCorp
Ontico
 
Automating aws infrastructure and code deployments using Ansible @WebEngage
Automating aws infrastructure and code deployments using Ansible @WebEngageAutomating aws infrastructure and code deployments using Ansible @WebEngage
Automating aws infrastructure and code deployments using Ansible @WebEngage
Vishal Uderani
 
Ansible Intro - June 2015 / Ansible Barcelona User Group
Ansible Intro - June 2015 / Ansible Barcelona User GroupAnsible Intro - June 2015 / Ansible Barcelona User Group
Ansible Intro - June 2015 / Ansible Barcelona User Group
Orestes Carracedo
 
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014
Miguel Zuniga
 
Forget MAMP and WAMP, Use Virtual Box to Have a Real Ubuntu Server
Forget MAMP and WAMP, Use Virtual Box to Have a Real Ubuntu ServerForget MAMP and WAMP, Use Virtual Box to Have a Real Ubuntu Server
Forget MAMP and WAMP, Use Virtual Box to Have a Real Ubuntu Server
aaroncouch
 
Automation in the Small: Code to Cloud
Automation in the Small: Code to CloudAutomation in the Small: Code to Cloud
Automation in the Small: Code to Cloud
Jay Barker
 
Ansible + WordPress - WordCamp Toronto 2016
Ansible + WordPress - WordCamp Toronto 2016Ansible + WordPress - WordCamp Toronto 2016
Ansible + WordPress - WordCamp Toronto 2016
Alan Lok
 
Automated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. AnsibleAutomated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. Ansible
Alberto Molina Coballes
 
Fake IT, until you make IT
Fake IT, until you make ITFake IT, until you make IT
Fake IT, until you make IT
Bas Meijer
 
Automating the Cloud with Terraform, and Ansible
Automating the Cloud with Terraform, and AnsibleAutomating the Cloud with Terraform, and Ansible
Automating the Cloud with Terraform, and Ansible
Brian Hogan
 
Using Aws As A Game Server (AWS UG Bandung)
Using Aws As A Game Server (AWS UG Bandung)Using Aws As A Game Server (AWS UG Bandung)
Using Aws As A Game Server (AWS UG Bandung)
Aswin Juari
 
Go Faster with Ansible (PHP meetup)
Go Faster with Ansible (PHP meetup)Go Faster with Ansible (PHP meetup)
Go Faster with Ansible (PHP meetup)
Richard Donkin
 
Network Automation with Ansible
Network Automation with AnsibleNetwork Automation with Ansible
Network Automation with Ansible
Anas
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
Dharmit Shah
 
DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!
Jeff Geerling
 

Viewers also liked (16)

Media big3
Media big3Media big3
Media big3
Melvina Kanu
 
It's All Sales, Selling and Defending UX
It's All Sales, Selling and Defending UXIt's All Sales, Selling and Defending UX
It's All Sales, Selling and Defending UX
Michael Zarro, Ph.D.
 
Shepherd asia rice_valuechains
Shepherd asia rice_valuechainsShepherd asia rice_valuechains
Shepherd asia rice_valuechains
Andrew Shepherd
 
Comonocreer(1)
Comonocreer(1)Comonocreer(1)
Comonocreer(1)
jose cruz
 
No Weights - No Problem
No Weights - No ProblemNo Weights - No Problem
No Weights - No Problem
Dr. Michael England
 
Resumen ponencia marco
Resumen ponencia marcoResumen ponencia marco
Resumen ponencia marco
JPMONTORO1
 
Mainstream UX
Mainstream UXMainstream UX
Mainstream UX
Carmel Hassan
 
Extreme Facts and Places
Extreme Facts and PlacesExtreme Facts and Places
Extreme Facts and Places
Dr. Michael England
 
Soluciones de Email Marketing y SMS masivo Mexico
Soluciones de Email Marketing y SMS masivo MexicoSoluciones de Email Marketing y SMS masivo Mexico
Soluciones de Email Marketing y SMS masivo Mexico
Carlos Cardona
 
Poblacion wayúu cultura y generalidades
Poblacion wayúu cultura y generalidadesPoblacion wayúu cultura y generalidades
Poblacion wayúu cultura y generalidades
Amanda Acosta Hernandez
 
Ficha cómo los griegos cambiaron el mundo ii
Ficha cómo los griegos cambiaron el mundo iiFicha cómo los griegos cambiaron el mundo ii
Ficha cómo los griegos cambiaron el mundo ii
satelite1
 
Project Report
Project ReportProject Report
Project Report
Alok Kumar Arya
 
Alejandro sanz investigación sergio
Alejandro sanz investigación sergioAlejandro sanz investigación sergio
Alejandro sanz investigación sergio
satelite1
 
Himno de extremadura
Himno de extremaduraHimno de extremadura
Himno de extremadura
CEIP VIRGEN DE LA CONSOLACIÓN Y CEIP NUESTRA SEÑORA DE LA ASUCION
 
Aben Resources - Investor Presentation
Aben Resources - Investor PresentationAben Resources - Investor Presentation
Aben Resources - Investor Presentation
Company Spotlight
 
Ad

Similar to Hosting a Rails App (20)

Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)
Jun Hong Kim
 
Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015
Alex S
 
OpenStack Summit 2013 Hong Kong - OpenStack and Windows
OpenStack Summit 2013 Hong Kong - OpenStack and WindowsOpenStack Summit 2013 Hong Kong - OpenStack and Windows
OpenStack Summit 2013 Hong Kong - OpenStack and Windows
Alessandro Pilotti
 
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
Luis Rodríguez Castromil
 
Hosting Ruby Web Apps
Hosting Ruby Web AppsHosting Ruby Web Apps
Hosting Ruby Web Apps
Michael Reinsch
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansible
Khizer Naeem
 
Detailed Introduction To Docker
Detailed Introduction To DockerDetailed Introduction To Docker
Detailed Introduction To Docker
nklmish
 
Kuby, ActiveDeployment for Rails Apps
Kuby, ActiveDeployment for Rails AppsKuby, ActiveDeployment for Rails Apps
Kuby, ActiveDeployment for Rails Apps
Cameron Dutro
 
Docker for everything
Docker for everythingDocker for everything
Docker for everything
Tim Haak
 
Cassandra and Docker Lessons Learned
Cassandra and Docker Lessons LearnedCassandra and Docker Lessons Learned
Cassandra and Docker Lessons Learned
DataStax Academy
 
Ansible Tutorial.pdf
Ansible Tutorial.pdfAnsible Tutorial.pdf
Ansible Tutorial.pdf
NigussMehari4
 
Deploying your rails application to a clean ubuntu 10
Deploying your rails application to a clean ubuntu 10Deploying your rails application to a clean ubuntu 10
Deploying your rails application to a clean ubuntu 10
Maurício Linhares
 
Pure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talkPure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talk
Bryan Ollendyke
 
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
Gaetano Giunta
 
Ansible - Hands on Training
Ansible - Hands on TrainingAnsible - Hands on Training
Ansible - Hands on Training
Mehmet Ali Aydın
 
Automating Complex Setups with Puppet
Automating Complex Setups with PuppetAutomating Complex Setups with Puppet
Automating Complex Setups with Puppet
Kris Buytaert
 
Deployment of WebObjects applications on CentOS Linux
Deployment of WebObjects applications on CentOS LinuxDeployment of WebObjects applications on CentOS Linux
Deployment of WebObjects applications on CentOS Linux
WO Community
 
Using Puppet in Small Infrastructures
Using Puppet in Small InfrastructuresUsing Puppet in Small Infrastructures
Using Puppet in Small Infrastructures
Rachel Andrew
 
Automating with Ansible
Automating with AnsibleAutomating with Ansible
Automating with Ansible
Ricardo Schmidt
 
Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015
Alex S
 
Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)
Jun Hong Kim
 
Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015
Alex S
 
OpenStack Summit 2013 Hong Kong - OpenStack and Windows
OpenStack Summit 2013 Hong Kong - OpenStack and WindowsOpenStack Summit 2013 Hong Kong - OpenStack and Windows
OpenStack Summit 2013 Hong Kong - OpenStack and Windows
Alessandro Pilotti
 
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
Luis Rodríguez Castromil
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansible
Khizer Naeem
 
Detailed Introduction To Docker
Detailed Introduction To DockerDetailed Introduction To Docker
Detailed Introduction To Docker
nklmish
 
Kuby, ActiveDeployment for Rails Apps
Kuby, ActiveDeployment for Rails AppsKuby, ActiveDeployment for Rails Apps
Kuby, ActiveDeployment for Rails Apps
Cameron Dutro
 
Docker for everything
Docker for everythingDocker for everything
Docker for everything
Tim Haak
 
Cassandra and Docker Lessons Learned
Cassandra and Docker Lessons LearnedCassandra and Docker Lessons Learned
Cassandra and Docker Lessons Learned
DataStax Academy
 
Ansible Tutorial.pdf
Ansible Tutorial.pdfAnsible Tutorial.pdf
Ansible Tutorial.pdf
NigussMehari4
 
Deploying your rails application to a clean ubuntu 10
Deploying your rails application to a clean ubuntu 10Deploying your rails application to a clean ubuntu 10
Deploying your rails application to a clean ubuntu 10
Maurício Linhares
 
Pure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talkPure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talk
Bryan Ollendyke
 
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
Gaetano Giunta
 
Automating Complex Setups with Puppet
Automating Complex Setups with PuppetAutomating Complex Setups with Puppet
Automating Complex Setups with Puppet
Kris Buytaert
 
Deployment of WebObjects applications on CentOS Linux
Deployment of WebObjects applications on CentOS LinuxDeployment of WebObjects applications on CentOS Linux
Deployment of WebObjects applications on CentOS Linux
WO Community
 
Using Puppet in Small Infrastructures
Using Puppet in Small InfrastructuresUsing Puppet in Small Infrastructures
Using Puppet in Small Infrastructures
Rachel Andrew
 
Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015
Alex S
 
Ad

Recently uploaded (20)

Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 

Hosting a Rails App

  • 2. Why am I presenting this? • Level Seven • Support a bunch of production rails apps • Biggest has between 20- 30 boxes of various types • Still learning
  • 3. We’re Hiring! • Ya i know, who isn’t? • Full time ruby on rails • Happy to help someone pick up their first real rails gig • Also we like contractors and independents
  • 4. Hosting Options • Heroku • Great for new/young projects • Easy to manage • Gets expensive quick • Pretty inflexible, very little control • AWS • More complicated setup • Can also get expensive but easier to control (YMMV) • Awesome set of tools that all play well together • You need to know or be a sysadmin
  • 5. Free Micro Instance • Everything in this presentation you can try out for yourself for free • Amazon Free Tier • Free Micro EC2 Instance, 1 static IP, 30 gig EBS space and a load balancer plus a bunch of other stuff • http://aws.amazon.com/free/ • Any code / scripts will be on github and these slides will be on slideshare. I’ll tweet their location after the talk. • I have a bunch of hidden slides that screenshot the amazon setup process too
  • 6. Step 0: Assumptions & Spinup • We’ll be using an Ubuntu 12.01 instance. It’s a default in AWS. • This guide is really Amazon stack heavy. I’ve worked with it, heroku and rackspace (a little) so if you have questions I’m happy to try and help. • You should setup an elastic IP on your server right away for easy of use, but I’ll talk about it later on.
  • 7. Step 0: Assumptions & Spinup • First spinup a new instance on EC2 using Ubuntu 13.04 • Ideally add a 2nd EBS volume with additional storage space • Associate an Elastic IP with that box • Setup a new Host record in ~/.ssh/config for the new server Host ClerbDemo HostName 107.20.194.126 IdentityFile ~/.ssh/AWSJosh.pem ForwardAgent yes • That last line will be important later
  • 8. Step 1 - Dependencies • Install the various libraries and dev tools you’ll need to install the rest of the server > sudo apt-get -y update #update apt to the latest packages > sudo apt-get -y install build-essential zlib1g-dev libssl-dev libreadline-dev libyaml-dev libcurl4-openssl-dev curl git-core python- software-properties libxslt-dev libxml2-dev imagemagick pdftk openjdk-7-jre-headless • Install NodeJS for Asset Pipeline > sudo apt-add-repository -y ppa:chris-lea/node.js > sudo apt-get -y update > sudo apt-get -y install nodejs
  • 9. Step 1 - Dependencies • Make your life better by disabling rdoc and ri installation for gems > sudo echo “gem: --no-ri --no-rdoc” >> ~/.gemrc > echo “gem: --no-ri --no-rdoc” >> ~/.gemrc • Set your timezone (optional, maybe you want UTC) >sudo dpkg-reconfigure tzdata #We use America/New York
  • 10. Step 2 - Ruby • 2 Ways to install, from source or via a system-wide RVM install • RVM is really only useful if you plan on having multiple rubies • Passenger 4 supports this and may result in me changing my defaults pretty soon • For now we’ll go with source > wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz > tar -xzvf ruby-2.0.0-p0.tar.gz > cd ruby-2.0.0-p0 > ./configure > make > sudo make install • dd
  • 11. Step 3 - Web Server • Lots of choices. Apache or Nginx w/ Passenger, Thin, Unicorn, etc. • We’ll go with Apache w/ Passenger • I REALLY like nginx but I haven’t used it enough yet > sudo apt-get install apache2 apache2-mpm-prefork apache2- prefork-dev > sudo gem install passenger > sudo passenger-install-apache2-module # Follow instructions on screen
  • 12. Step 3 - Web Server • Setup the modules you’ll need > sudo a2enmod ssl > sudo a2enmod rewrite > sudo a2enmod headers > sudo a2enmod expires > sudo a2enmod passenger • We’ll need a virtual host for the site but we’ll do that later once we have the code out there for the first time • I like to setup the folder paths now though > sudo mkdir /srv/www > sudo chown ubuntu /srv/www > sudo chgrp ubuntu /srv/www
  • 13. Step 4 - Database • Tons of options, popular ones include Postgres, MySQL for RDBMS or MongoDB as NoSQL Alternative • If you like MySQL you could use Amazon’s RDS Service • We’ll go with PSQL for now > sudo touch /etc/apt/sources.list.d/pgdg.list > sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" >> /etc/apt/sources.list.d/pgdg.list' >wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add - > sudo apt-get -y update > sudo apt-get -y install postgresql-9.2 • If your using a different DB and App server you have to modify the postgres config to allow remote connections
  • 14. Step 5 - DNS & IP Addresses • For AWS your server will need an elastic IP • You’ll need to setup that address in DNS, lots of options here: • I recommend either Amazon’s Route 53 or DNSimple • Both have great APIs, allow a lot of flexibility and aren’t Godaddy • Setup an A Record to point to the IP address you got from amazon
  • 15. Deployment • Most rails apps on custom servers use capistrano • https://help.github.com/articles/deploying-with-capistrano • In short add capistano to your gemfile, bundle install, then: > capify . • Update the config/deploy.rb with your server info and path you want the code
  • 16. Deployment • cap deploy:setup to create folder structure • cap deploy:check to verify • At this point you should make sure you database.yml file is on the server in the proper place • cap deploy • cap deploy:migrations to deploy and run all migrations
  • 17. Deployment • You need a custom cap task for running asset pipeline generation • You can support multiple environments using capistrano/ext/multistage • I like to build a cap task to copy the real db config into my project post-deploy and not store production un/pw info in git
  • 18. Stuff I Forgot Earlier • You need to create a vhost in /etc/apache2/sites-available • Also make sure your security group allows traffic on port 80
  • 19. Stuff I didn’t cover • Failover including load balancing • Caching solutions like Varnish or advanced nginx caching • Proxy server configurations • Database replication or failover • Backup • Lots of other stuff...
  • 20. References • My Demo App • https://github.com/JoshReedSchramm/HostingRailsDemoApp • The Server Setup Script • https://github.com/JoshReedSchramm/HostingRailsDemoApp/blob /master/doc/setupscript.txt • These Slides • Some crazy slideshare url