SlideShare ist ein Scribd-Unternehmen logo
1 von 21
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

Weitere ähnliche Inhalte

Was ist angesagt?

Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015Chef
 
Monitor-Driven Development Using Ansible
Monitor-Driven Development Using AnsibleMonitor-Driven Development Using Ansible
Monitor-Driven Development Using AnsibleItamar Hassin
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationSuresh 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 AnsibleJeff Geerling
 
Mitchell Hashimoto, HashiCorp
Mitchell Hashimoto, HashiCorpMitchell Hashimoto, HashiCorp
Mitchell Hashimoto, HashiCorpOntico
 
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 @WebEngageVishal 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 GroupOrestes 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 2014Miguel 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 Serveraaroncouch
 
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 CloudJay Barker
 
Ansible + WordPress - WordCamp Toronto 2016
Ansible + WordPress - WordCamp Toronto 2016Ansible + WordPress - WordCamp Toronto 2016
Ansible + WordPress - WordCamp Toronto 2016Alan Lok
 
Automated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. AnsibleAutomated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. AnsibleAlberto Molina Coballes
 
Fake IT, until you make IT
Fake IT, until you make ITFake IT, until you make IT
Fake IT, until you make ITBas 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 AnsibleBrian 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 AnsibleAnas
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansibleDharmit Shah
 

Was ist angesagt? (20)

Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015Chef Provisioning a Chef Server Cluster - ChefConf 2015
Chef Provisioning a Chef Server Cluster - ChefConf 2015
 
Monitor-Driven Development Using Ansible
Monitor-Driven Development Using AnsibleMonitor-Driven Development Using Ansible
Monitor-Driven Development Using Ansible
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
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
 
Mitchell Hashimoto, HashiCorp
Mitchell Hashimoto, HashiCorpMitchell Hashimoto, HashiCorp
Mitchell Hashimoto, HashiCorp
 
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
 
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
 
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
 
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
 
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
 
Ansible + WordPress - WordCamp Toronto 2016
Ansible + WordPress - WordCamp Toronto 2016Ansible + WordPress - WordCamp Toronto 2016
Ansible + WordPress - WordCamp Toronto 2016
 
Ansible Case Studies
Ansible Case StudiesAnsible Case Studies
Ansible Case Studies
 
Automated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. AnsibleAutomated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. Ansible
 
Fake IT, until you make IT
Fake IT, until you make ITFake IT, until you make IT
Fake IT, until you make IT
 
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
 
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)
 
Go Faster with Ansible (PHP meetup)
Go Faster with Ansible (PHP meetup)Go Faster with Ansible (PHP meetup)
Go Faster with Ansible (PHP meetup)
 
Network Automation with Ansible
Network Automation with AnsibleNetwork Automation with Ansible
Network Automation with Ansible
 
Ansible - A 'crowd' introduction
Ansible - A 'crowd' introductionAnsible - A 'crowd' introduction
Ansible - A 'crowd' introduction
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
 

Andere mochten auch

Andere mochten auch (16)

Media big3
Media big3Media big3
Media big3
 
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
 
Shepherd asia rice_valuechains
Shepherd asia rice_valuechainsShepherd asia rice_valuechains
Shepherd asia rice_valuechains
 
Comonocreer(1)
Comonocreer(1)Comonocreer(1)
Comonocreer(1)
 
No Weights - No Problem
No Weights - No ProblemNo Weights - No Problem
No Weights - No Problem
 
cummins program
cummins programcummins program
cummins program
 
Resumen ponencia marco
Resumen ponencia marcoResumen ponencia marco
Resumen ponencia marco
 
Mainstream UX
Mainstream UXMainstream UX
Mainstream UX
 
Extreme Facts and Places
Extreme Facts and PlacesExtreme Facts and Places
Extreme Facts and Places
 
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
 
Poblacion wayúu cultura y generalidades
Poblacion wayúu cultura y generalidadesPoblacion wayúu cultura y generalidades
Poblacion wayúu cultura y generalidades
 
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
 
Project Report
Project ReportProject Report
Project Report
 
Alejandro sanz investigación sergio
Alejandro sanz investigación sergioAlejandro sanz investigación sergio
Alejandro sanz investigación sergio
 
Himno de extremadura
Himno de extremaduraHimno de extremadura
Himno de extremadura
 
Aben Resources - Investor Presentation
Aben Resources - Investor PresentationAben Resources - Investor Presentation
Aben Resources - Investor Presentation
 

Ähnlich wie Hosting a Rails App

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, 2015Alex 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 WindowsAlessandro Pilotti
 
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuis Rodríguez Castromil
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansibleKhizer Naeem
 
Detailed Introduction To Docker
Detailed Introduction To DockerDetailed Introduction To Docker
Detailed Introduction To Dockernklmish
 
Kuby, ActiveDeployment for Rails Apps
Kuby, ActiveDeployment for Rails AppsKuby, ActiveDeployment for Rails Apps
Kuby, ActiveDeployment for Rails AppsCameron Dutro
 
Docker for everything
Docker for everythingDocker for everything
Docker for everythingTim Haak
 
Cassandra and Docker Lessons Learned
Cassandra and Docker Lessons LearnedCassandra and Docker Lessons Learned
Cassandra and Docker Lessons LearnedDataStax Academy
 
Ansible Tutorial.pdf
Ansible Tutorial.pdfAnsible Tutorial.pdf
Ansible Tutorial.pdfNigussMehari4
 
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 10Maurício Linhares
 
Pure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talkPure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talkBryan 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 PuppetKris 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 LinuxWO Community
 
Using Puppet in Small Infrastructures
Using Puppet in Small InfrastructuresUsing Puppet in Small Infrastructures
Using Puppet in Small InfrastructuresRachel 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, 2015Alex S
 

Ähnlich wie 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)
 
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
 
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
 
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
 
Hosting Ruby Web Apps
Hosting Ruby Web AppsHosting Ruby Web Apps
Hosting Ruby Web Apps
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansible
 
Detailed Introduction To Docker
Detailed Introduction To DockerDetailed Introduction To Docker
Detailed Introduction To Docker
 
Kuby, ActiveDeployment for Rails Apps
Kuby, ActiveDeployment for Rails AppsKuby, ActiveDeployment for Rails Apps
Kuby, ActiveDeployment for Rails Apps
 
Docker for everything
Docker for everythingDocker for everything
Docker for everything
 
Cassandra and Docker Lessons Learned
Cassandra and Docker Lessons LearnedCassandra and Docker Lessons Learned
Cassandra and Docker Lessons Learned
 
Ansible Tutorial.pdf
Ansible Tutorial.pdfAnsible Tutorial.pdf
Ansible Tutorial.pdf
 
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
 
Pure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talkPure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talk
 
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 ...
 
Ansible - Hands on Training
Ansible - Hands on TrainingAnsible - Hands on Training
Ansible - Hands on Training
 
Automating Complex Setups with Puppet
Automating Complex Setups with PuppetAutomating Complex Setups with Puppet
Automating Complex Setups with Puppet
 
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
 
Using Puppet in Small Infrastructures
Using Puppet in Small InfrastructuresUsing Puppet in Small Infrastructures
Using Puppet in Small Infrastructures
 
Automating with Ansible
Automating with AnsibleAutomating with Ansible
Automating with Ansible
 
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
 

Kürzlich hochgeladen

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 

Kürzlich hochgeladen (20)

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 

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
  • 21. Questions & Contact • @JoshReedSchramm • josh.schramm@gmail.com or josh.schramm@lvlsvn.com