Join the Webbynode Community

Webbynode Forum » Installation & Configuration

Multiple Rails Applications in Subdomains

(7 posts)
  • Started 1 year ago by dcrowder32
  • Latest reply from tgraham
  1. dcrowder32

    offline
    Member

    This post shows you how to install/run multiple Rails applications in different subdomains. As always, use these instructions at your own risk and backup everything before.

    Assumptions:

    1. Running the Rails ReadyStack - Ubuntu 8.10, Apache2, Passenger
    2. Your web server is running with document root at /var/www
    3. Your Rails apps are in /var/rails
    4. Your domain is yourdomain.com. Obviously, change it to yours where needed.

    Procedure:

    Create the first app:

    1. Go to the rails directory
      cd /var/rails
    2. Make a new rails app in /var/rails
      rails app1
    3. Delete the default index file
      rm app1/public/index.html
    4. Go to the web server root directory
      cd /var/www
    5. Make symbolic links to the app
      ln -s /var/rails/app1/public one
    6. Go to the Apache config directory
      cd /etc/apache2/sites-available
    7. Create file for app
      touch one
    8. Put the following into the file with the editor of your choice
      <VirtualHost *:80>
      ServerName one.yourdomain.com
      DocumentRoot /var/rails/app1/public
      </VirtualHost>
    9. Enable the app.
      a2ensite one
      This creates a symbolic in sites-enabled to this file.

    Create the second app:

    1. Go to the rails directory
      cd /var/rails
    2. Make a new rails app in /var/rails
      rails app2
    3. Delete the default index file
      rm app2/public/index.html
    4. Go to the web server root directory
      cd /var/www
    5. Make symbolic links to the app
      ln -s /var/rails/app2/public two
    6. Go to the Apache config directory
      cd /etc/apache2/sites-available
    7. Create file for app
      touch two
    8. Put the following into the file with the editor of your choice
      <VirtualHost *:80>
      ServerName two.yourdomain.com
      DocumentRoot /var/rails/app2/public
      </VirtualHost>
    9. Enable the app.
      a2ensite two
      This creates a symbolic in sites-enabled to this file.

    Restart Apache:

  2. /etc/init.d/apache2 reload or /etc/init.d/apache2 restart
  3. Disable the default app?

  4. a2dissite default
  5. Update the DNS settings of your webby account:

    1. Login to webbynode manager
    2. Select the 'DNS' tab
    3. Select your domain (or 'New zone' button to create it if it does not exist)
    4. Click the 'New record' button
    5. Set 'Type' to "A"
    6. 'Name' to "one"
    7. 'Data' to the IP address of your webby
    8. Leave 'Auxillary Data' and 'TTL' at the defaults.
    9. Click the 'Save record' button
    10. Click the 'New record' button
    11. Set 'Type' to "A"
    12. 'Name' to "two"
    13. 'Data' to the IP address of your webby
    14. Leave 'Auxillary Data' and 'TTL' at the defaults.
    15. Click the 'Save record' button

    That is pretty much it. Work on your apps and browse to them at one.yourdomain.com and two.yourdomain.com.

Posted 1 year ago #
  • pygi

    offline
    Member

    Hey,

    thanks for the tutorial. Did you have a chance to check out the one in our howto? It needs to be improved, but it should work. Anyway ... interested in working with me on improving it? :)

    Cheers.

    Posted 1 year ago #
  • dcrowder32

    offline
    Member

    I did not get too far with it. It is not as detailed as I needed, being less experienced with Apache/DNS. Travis helped me quite a bit today.

    Posted 1 year ago #
  • meskyanichi

    offline
    Member

    @dcrowder32, mistake for "disabling" a website.

    Disable the default app?
    a2ensite default[/*]

    should be:

    a2dissite default

    Also, I recommend you to add this line in the /etc/apache2/apache2.conf
    NameVirtualHost *:80

    (before the "Include /etc/apache2/sites-enabled/" line)

    It's (afaik) required if you have multiple <VirtualHost>'s, at least, when I tried, it was required.

    Meskyanichi
    Ruby on Rails Web Developer
    Twitter: http://twitter.com/meskyanichi/
    Posted 1 year ago #
  • dcrowder32

    offline
    Member

    @meskyanichi, you are correct. I would correct it in the orignial post, but the 'edit' link no longer shows up.

    Posted 1 year ago #
  • meskyanichi

    offline
    Member

    @ dcrowder32, Yeah. After a while it seems you are unable to edit previous posts. :/

    Posted 1 year ago #
  • tgraham

    offline
    Staff

    I went in and fix it a little for you. I'll check on the time to edit posts as well.

    Travis

    Posted 1 year ago #
  • Reply

    You must log in to post.