0

I've followed Ryan Bate's guide to deploy two completely different rails apps one one VPS (cost saving, using it for development of small home projects). Link to railscast: http://railscasts.com/episodes/335-deploying-to-a-vps

My issue is: the default application is the one I deployed first, so when I visit the IP address, that is the app which is displayed. How do I configure the server to

  1. Use a subdomain (not sure this is possible using just an IP address)
  2. Change the default app

Had a play around in nginx.conf and read this stack q: NGinx Default public www location?

I can't seem to work it out! Thanks in advance.

Community
  • 1
  • 1
wkdshot
  • 256
  • 1
  • 6
  • 18

1 Answers1

0

I think I understand what you want to do. Your default app term confuses me. Let's throw that out and just say you want to deploy two different rails apps to different domains-- sub or TLD, it doesn't matter. Also, I think you are wanting to deploy them to the same VPS server. Ryan's screencast doesn't include how to do this.

What you are probably looking for is how to host multiple sites (and rails apps) with nginx. Like Ryan's screencast, there are many steps involved to get everything working. I recommend you first focus on domain setup (DNS), then nginx setup. Leaving serving your rails app with unicorn for last.

First

Setup your domain and subdomain to point to the VPS. One way is to create DNS A records point to your VPS IP.

Second

Configure nginx to serve both sites. To get you started in the right direction I recommend you read this: multiple websites on nginx & sites-available. It sounds like you already have nginx serving your app on your domain. So steps might be like:

 $ cd /etc/nginx/sites-available/
 $ cp default subdomain.example.com

Edit subdomain.example.com accordingly. See nginx docs for details. Also, make sure /sites-available/default and /sites-available/subdomain.example.com are not using _ as server_name directive. Set them to their respective domain names. Also, for now point the root to somewhere that will serve an index.html file (ie. leave rails out of it for now)

 $ cd /etc/nginx/sites-enabled/
 $ ln -s ../sites-available/eden.jrutherford.com .
 $ service nginx restart

If all is well by this point you should be able to visit both domains in a browser and have nginx serve content.

Third

Configure a new unicorn for your subdomain. I'm sorry I don't have specific tips for this step . Follow Ryan's tutorial, search google, unicorn website.

Good Luck.

Community
  • 1
  • 1
Jason R
  • 2,085
  • 20
  • 12