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.
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