Click here to Skip to main content
12,751,306 members (36,114 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

10.6K views
Posted 8 Aug 2014

Ruby on Rails On Windows Server With Helicon Zoo

, 8 Aug 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
ROR in production Windows

Introduction

We had to need for a server that would run many small web applications from C#, VB, ROR, PHP. Our admins have some Linux experience, but it would help us all out if it would be on Windows. So I set out on a quest to see if this could be done. Many frustrating days later I was able to get a working instance running.

Steps to follow

First of all you should have NO spaces in any of your path names. This article is also assuming your are installing Ruby 2.0.0-p481 (x64) and DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe on Windows Server 2012 x64.

  1. To ensure there are no conflicts make sure there is no entry about ruby in your default path environment variables. This will all be set with in the Helicon Zoo.
  2. Downlaod and install the Ruby installer and DevKit at http://rubyinstaller.org/ . Installing Ruby seperately is not required if you are happy with the older version that is installed with Helicon Zoo.
    1. Installed Ruby 2.0 x64 and devkit x64 (They are two different downloads on the installer site.) This is because Helicon does not come with the latest version of Ruby.
    2. Do the default install (Nothing checked)
    3. Copy or extract the devkit (you will have to create this folder) extracted files into c:\{Ruby files}\devkit
  3. "Install Devkit". Ruby must know that the DevKit exist, so it must be installed. If it is not installed you will get errors later on about gems requiring build tools. (http://stackoverflow.com/questions/8100891/the-json-native-gem-requires-installed-build-tools)
    1. Open up the ruby console. The console will not be an option if there is an existing install of Ruby, so you should uninstall other versions prior to this one.
    2. cd C:\{ruby install dir}\DevKit
    3. "ruby dk.rb init"
    4. "ruby dk.rb review"
      1. If this throws an error about invalid config.yml edit the file in your c:\{ruby folder}\DevKit and enter "- c:/{ruby folder}" at the bottom of the file.  (note the forward slash)
    5. "ruby dk.rb install" (now when you need to compile something it will know where devkit is.)
  4. Install the web platform installer 5.0 (http://www.microsoft.com/web/downloads/platform.aspx)
  5. Add the custom feed of "http://www.helicontech.com/zoo/feed.xml". This step is shown here: http://www.helicontech.com/articles/ruby-on-rails-on-windows-in-production/
    1. Add Ruby project and click install. (This can take several minutes depending on your connection and speed of your computer.)
    2. At the end of the install it will end on the Configure section, just accept the default options. This will give you something to play with.
    3. Close the web installer when done.
  6. Open up Helicon Zoo manager from the applications and click "applicationHost.config" (It's a tab at the top). Find the engines tag and add a new user engine at the after <\engines>. Make sure to save the change and choose refresh at the top of the window then close.
    1.     <userEngines>
          <add name="ruby.2.0x64.rack" displayName="Ruby 2.0 x64 rack" fullPath="%SystemDrive%\Ruby200-x64\bin\ruby.exe" arguments="%SystemDrive%\Zoo\Workers\ruby\zoorack.rb" transport="NamedPipe" protocol="fastcgi">
                  <environmentVariables>
                      <add name="CURRENT_DIRECTORY" value="%APPL_PHYSICAL_SHORT_PATH%" />
                      <add name="HOME" value="%APPL_PHYSICAL_SHORT_PATH%" />
                      <add name="GEM_HOME" value="%APPL_PHYSICAL_SHORT_PATH%\GEM_HOME" />
                      <add name="GEM_PATH" value="%GEM_HOME%" />
                      <add name="Path" value="%GEM_HOME%\bin;%SystemDrive%\Ruby200-x64\bin;%SystemDrive%\Ruby200-x64\devkit\bin;%Path%" />
                      <!-- The below environment varaibles were added by Corey. I guess they sould be ok here. -->
                      <add name="RACK_ENV" value="production" />
                      <add name="RAILS_RELATIVE_URL_ROOT" value="%APPL_VIRTUAL_PATH%" />
                      <!--This is just a place holder. The value gets placed here only after this template is copied -->
                      <add name="SECRET_KEY_BASE" value="" />            
                  </environmentVariables>
              </add>
          </userEngines>
          
    2. The engine should be added any time a new version of ruby comes out.
    3. Close the Zoo manager and go to IIS and Add a new application under the default website. (Do NOT name it test. This is reserved in ruby)
  7. In IIS right click default website and add application. The alias should be all lower case (I have noticed this is case sensitive). Set the physical path.
    1. Set the path to C:\inetpub\wwwroot\{Your app name here, no spaces}
    2. Make sure to set the proper rights to the folder. Grant write access to "IIS_IUSRS" to the folder. This should be temporary and removed once you are done with configuration.
    3. Open up Helicon zoo with in the site that was created (You will see the Zoo icon in IIS).
      1. Add a new application
      2. Name it "Ruby.2.0.rack" (Not sure if the name really matters.)
      3. Select the engine that was created in the config file.
      4. Ensure you have the environment variables RACK_ENV=production,RAILS_RELATIVE_URL_ROOT=%APPL_VIRTUAL_PATH%,SECRET_KEY_BASE
        1. The variables should of been copied over from the custom engine that was added.
      5. Click Apply and the next Apply.
    4. Click your App name in the site list on the far left, this will cause Helicon Zoo to refresh enabling the Web Console.
      1. Navigate back to Zoo icon and click Start webconsole. If the webconsole ever hanges close any instances of IIS Worker Process to restore it.
      2. At the Web console
        1. type in "gem install rails" (this can take a while 10+ minutes) If you get a permissions issue you forgot to allow access to IIS_IUSRS.
        2. If you get errors about "unable to convert X from ASCII-IBIT to UTF-8..."
          1. try "gem install rdoc" then "gem rdoc --all --overwrite" (http://stackoverflow.com/questions/18235293/ruby-on-rails-unable-to-convert-x89-from-ascii-8bit-to-utf-8-for-xxx-xxxx-x)
          2. Copy your project over now or run "rails new ." to create a new rails app.
          3. "bundle install" and your new rails app is ready
    5. Navigate to http://localhost/{Your app name using the SAME case as what is in IIS}
      1. If you get an error about key missing for production
        1. Generate the secret key for production by typing "rake secret", once you have the ky go back to the environment variables and fill in SECRET_KEY_BASE.
      2. If you get an error about "DataSourceNotFound" (http://stackoverflow.com/questions/23022258/tzinfodatasourcenotfound-error-starting-rails-v4-1-0-server-on-windows))
        1. Edit your existing gem file and replace your "gem 'tzinfo-data'" line with "gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]". Note that you are adding ":x64_mingw"
        2. Run "bundle update" on the console window
      3. If you run into issues about your JS files having scripting issues or you notice none of your static files are be served / not found then try this: (http://stackoverflow.com/questions/7829480/no-route-matches-get-assets)
        1. Modify your config/environments/production.rb and set config.serve_static_assets to true.
        2. For this to work though, they must be precompiled.

 

Here are some notes I had when connecting my ROR project to SQL Server. (https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/Using-TinyTDS)

  1. gem install tiny_tds
    gem install activerecord-sqlserver-adapter
  2. Modify your database.yml with the connection information outlined in the link above.
  3. The database connection changes require a site restart. I think you can just Kill the instance of the Ruby Interperter too.
  4. If you have issues with division specifically money. I had to add ".to_d" to the calculated fields because they were being treated as integers.

Points of Interest

I ran into so many issues trying to get this working. I did try Ubuntu and CentOS and found random issues with it too, so this is not isolated to Windows. Granted I wanted to use RVM in the Linux distrbutions. This woudl allow me to run various versions of Rails or Ruby. I feel that using Helicon Zoo with ROR is far superior allowing you to mix and match Ruby and Rails and are 100% isolated from each other.

History

  • 08/08/14 - Initial release of instructions.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Corey Fournier
Software Developer
United States United States
Graduate of University of Louisiana at Lafayette in computer science.

You may also be interested in...

Comments and Discussions

 
QuestionSlow start of Ruby application Pin
Member 1124487118-Nov-14 12:19
memberMember 1124487118-Nov-14 12:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170215.1 | Last Updated 8 Aug 2014
Article Copyright 2014 by Corey Fournier
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid