0
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

posted at

configure IIS with ruby on rails app on windows server

As the title looks strange, RubyOnRails application deploy on Windows Server??? really???

Yes, today I would like to share my experience, how I managed to deploy a Ruby application on the window server(IIS).

Most of the Ruby applications are deploying on a Linux system(cents, ubuntu, AMI) & as the performance perspective, which is also very good and the developer also prefers to develop on Linux systems, because all gems are easily installed on Linux machine in compare to install on the Windows machine.

Let's back to the topic,
In the year 2018, we released Ruby application on the Windows server and It's almost 1.5 years, it's running perfectly without having any big issue.
Regarding the issue, I will discuss it later.

Sharing the System architecture with you all. If you find helpful then please share and leave your comments.
Screen Shot 2020-01-17 at 21.46.10.png

At 1st we started development on the Linux machine, but suddenly we get to knew that we have to release it on the Windows server(IIS). At that time we discussed all the pros and cons with the client and within a team, but it's a God wish to get in a new ride. We accepted this challenge.

Before going deep into it,
I researched how much it is practical to deploy the RubyonRails app on production env(Window Server). I found some articles over the internet but looks like deploy on development env.

Sharing the application details.
・Language: Ruby
・Framework: Rails
・Database: SQL Server 2014
・Platform: Windows Server(2012)
・Application Server: Puma

Now it's time to get it into the windows server.

Step 1: Installation of the Ruby and Rails framework.
This step is quite easy because I already did the same in the past. so 1st step is clear.

Step 2: Run our application on Windows.
As you all know that rails provide the puma server as default, so I used puma and there are some dependency issues but resolved it successfully. And finally, our application is on running mode.

Step 3: IIS Installation.
You can find many articles to Install IIS. As we need to follow some steps to install IIS. So this step is also clear without having any problem.

Step 4: Deploy app on IIS.
Open IIS Manager, then Go to the Site, Right-click on Default Web Site and Add New Application.
As the below image described.
2019-10-09 11_02_17-API-SVR57 - TeamViewer.jpg

Step 5: Configration web.config file.
This step was the most difficult. WHY???
Because 1st you have to create a web.config file with all the basic settings for the Ruby app.
2nd the web.config file location(where should I keep this file, inside the ruby application folders or outside).
3rd is, how to run a puma server in IIS.

I tried many settings, did many changes in the IIS and configuration files.
but no luck.

and finally, the day has come, when I got successfully run a Ruby application in IIS.
yeah....cheers.

1st below is the web.config file for your reference.
2nd, please copy your web.config file under your mail directory. (please check the below image.)
3rd, please check the web.config file below.

Setup and configuration have been completed.
2019-10-09 11_00_54-API-SVR57 - TeamViewer.jpg

Step 6: How to do set up an environment(run an app on development or production mode?).
In apache or Nginx, it is easy to define the environment. but in IIS it was not an easy task.
So the next hurdler was: run our application on development and as well as production env.
here is the web.config for the development & production env.
■ Development Env:

    <?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />            
        </handlers>
        <httpPlatform stdoutLogEnabled="true" processesPerApplication="1" stdoutLogFile="log\rails.log" startupTimeLimit="20" processPath="C:\Ruby24-x64\bin\ruby.exe" arguments="-S puma --env development --dir C:\inetpub\wwwroot\live\<your-project-folder-name> -p %HTTP_PLATFORM_PORT% ">
            <environmentVariables>              
              <environmentVariable name="RAILS_ENV" value="development" />        
            </environmentVariables>            
        </httpPlatform>        
    </system.webServer>    
</configuration>

■ Production Env:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />            
        </handlers>
        <httpPlatform stdoutLogEnabled="true" processesPerApplication="1" stdoutLogFile="log\rails.log" startupTimeLimit="20" processPath="C:\Ruby24-x64\bin\ruby.exe" arguments="-S puma --env production --dir C:\inetpub\wwwroot\live\<your-project-folder-name> -p %HTTP_PLATFORM_PORT% ">
            <environmentVariables>              
              <environmentVariable name="RAILS_ENV" value="production" />  
              <environmentVariable name="SECRET_KEY_BASE" value="<generate-your-secret-key>" />         
            </environmentVariables>            
        </httpPlatform>        
    </system.webServer>    
</configuration>

Till date, it is running perfectly.
But this was a very interesting and new combination(ruby on rails on IIS).

If you have the same scenario then please go through this article. I hope it will be helpful.

■Problem
In the last, I want to share one problem with you guys,
sometimes the IIS server stopped suddenly, so at that time we need to restart it. Looking for the solution...

If you find anything wrong within this article then please let me know.

Thank you for your valuable​ time.

Enjoy Coding.:smiley::smiley:

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
0
Help us understand the problem. What are the problem?