Skip to main content

Deploy Multiple Rails Apps to Same DigitalOcean Droplet?

General • Asked by Michael Stitt


I've used your guide to deploy a Rails app to a DO droplet -- which was extremely helpful! However, now I'm at the point where I'd like to take advantage of this existing droplet and deploy other Rails apps that I'm working on (mostly just landing pages at the moment).

Do you have any advice on how to go about this or can you point to any documentation implementing this? Are there any things I need to think about when sharing a VPS with multiple Rails apps?

Thanks!

Gravatar Chris Oliver commented on : Mod Staff

You'll love this, it's almost too simple.

For your new app, you can basically copy the Capistrano configs from the old one and change the app name in all the places. You'll need to add another server block to your Nginx config, restart Nginx, and create a new database for this app. That's it. Just deploy like you did before, and create the database.yml file on the server to point to the new database and you're off to the races.

Changing the domain name in the nginx config and pointing a second domain to the same server is all you need to do in order to have Nginx serve up two sites from the same machine.

You can basically just follow those same steps from the guide, but skip the installation parts and go straight to the nginx config, database, and capistrano pieces.

Sweet! I'll do that later today and let you know if I run into any hiccups.

Thanks again for producing great content on such a consistent basis!

Gravatar Chris Oliver commented on : Mod Staff

You got it! :) I appreciate that a lot. I've been trying to make sure it all stays up-to-date as much as possible.

Lemme know if you hit any snags!

Hi, I am getting the same issue, i followed your server setup tutorial and it works fine. but now i want to deploy another rails application on same server, i dont know how to configure my next application. My default file (/etc/nginx/sites-enabled/default) settings are given.

Default settings

server {

    listen 80;
    listen [::]:80 ipv6only=on;
            server_name mydomain.com;
    passenger_enabled on;
    rails_env    production;
    root         /home/ubuntu/projects/blog/public;
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

}
Please guide me how to configure more apps. If you can show me the code example it'll be more helpful.
Thanks in advance.

Gravatar Chris Oliver commented on : Mod Staff

Hey Muneeb,

Just create a new file in the /etc/nginx/sites-enabled directory. Name it whatever you want, just not default since that's already being used.

Hi Chris,

Thank you so much for your reply. I did the same thing. I created a new file in sites-enabled same name as my project and paste the configurations as
server {

listen 80;
listen [::]:80 ipv6only=on;
        server_name mydomain.com;
passenger_enabled on;
rails_env    production;
root         /home/ubuntu/projects/site2/public;
error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   html;
}

}

But it is giving me an error that port 80 is already used. but when i changed port form 80 to 8080 this is not accessable from browser. i am using ubuntu 16.4.

Gravatar Chris Oliver commented on : Mod Staff

Hey Muneeb,

Check out this post and the comment on solutions for that. https://stackoverflow.com/a/15101745/277994

Login or create an account to join the conversation.