Reputation: 18064
How can I deploy a Rails app to a VPS (virtual private server) or a dedicated server? It would be nice to have an easy to follow guide.
I know about scripts to automate the process, but I think it's better to have everything under control, in order to understand better the process.
Upvotes: 8
Views: 6763
Reputation: 2999
As more up to dated and future proof answer I would suggest this page on this:
Upvotes: 0
Reputation: 18064
I have successfully deployed a heavy Rails application to Linode or Digital Ocean, using these technologies:
These are the steps that work for me:
Create a new virtual machine
Follow the setup instructions of your hosting, being Linode or Digital Ocean, to create the node and set it up.
Set up date
Update packages
Create user
Set up SSH key-authentication
On local:
On the server:
Set up SSH
Set up firewall
Set up fail2ban
Set up if you have enough free memory, as it tends to eat it.
Install Git
Install rbenv
Install Ruby
Install nginx + Passenger
Install PostgreSQL
Install node.js
Needed to pre-compile assets.
Install bundler
Create the user in PostgreSQL
Deploy the code * On the server: * sudo mkdir -p /srv/yoursite.com * sudo chown deploy:deploy /srv/yoursite.com * On your dev machine: * bundle exec cap production deploy:check (it will throw an error because it doesn't find the database) * On the server: * cd /srv/yoursite.com/shared/config * vim database.yml (paste your database config) * vim secrets.yml (paste your secrets config) * On your dev machine: * bundle exec cap production deploy * bundle exec cap production whenever:update_crontab
Configure logrotate
Upvotes: 44
Reputation: 41
I deployed my rails application to my production servers (it's a cluster) with Capistrano before, but I found that Capistrano is a bit complex and sometimes even became trouble maker... So I wrote my deployment script by bash shell script.
I have put it on github with a brief guide: deploy_rails
Upvotes: 1