Skip to content

Instantly share code, notes, and snippets.

@rjohnson4444
Last active March 4, 2016 22:55
Show Gist options
  • Save rjohnson4444/43b3bf5d3ce0a07499ba to your computer and use it in GitHub Desktop.
Save rjohnson4444/43b3bf5d3ce0a07499ba to your computer and use it in GitHub Desktop.
Serving a Rails application on a Digital Ocean droplet

First lets serve sqllite db on your droplet

ssh into your droplet ssh root@<ip-address>

rails new <appname> cd <appname> rails s

command-d to open slip window

ssh into droplet in a new terminal window.

curl localhost:3000

You should see the html of the server's response.

Now we will create a Rails app using postgres

Drop into postgres and create a roll for root user and set password.

su - postgres psql create role root with createdb login password 'complete'; contol-d to exit type exit

Create new rails app with postges as the database

rails new <appname> -d postgresql cd into rails app

Pull up text editor and go to the config/database.yml file

vim go into config/database.yml

Adjust username and password for production settings

username: root 
password: complete

Scaffold an Article

rails g scaffold Article title body:text

Create and migrate database

RAILS_ENV=production rake db:create db:migrate

Server app on port 80

RAILS_ENV=production rails s -d -b <ip-address> -p 80

Note: May need to hard code production secret codebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment