Using Puma and IIS on Windows
Puma is advertised as a small and fast server. It is derived from Mongrel, which is an open source web server written in Ruby by Zed Shaw. It can serve Redmine on its own, or behind Nginx, Apache, or IIS. Puma can be run and installed in a user's home directory or system-wide.
Getting ready
First, install Redmine as explained in the previous recipe.
Then, we need the OpenSSL Developer Package (this contains header files and binaries), which can be downloaded from http://packages.openknapsack.org/openssl/openssl-1.0.0k-x64-windows.tar.lzma. Considering that we followed the previous recipe precisely, if you need a different SSL version, you can obtain it from https://www.openssl.org. Now, perform the following steps:
- Download http://packages.openknapsack.org/openssl/openssl-1.0.0k-x64-windows.tar.lzma and copy it to
C:\ruby
. - Create a folder,
openssl
, inC:\ruby
and copy the downloaded OpenSSL lzma archive here. - Run cmd and navigate to
C:\ruby\openssl
by typing the following:cd C:\ruby\openssl
. Extract the content of the archive by typing:bsdtar --lzma -xf openssl-1.0.0k-x64-windows.tar.lzma
Note
If
minigw
bin fromdevkit
is not added to path, you must specify full folder in order to executebsdtar
, and it would look somewhat like this:c:\ruby\devkit\mingw\bin\bsdtar.exe --lzma -xf c:\ruby\openssl\openssl-1.0.0k-x64-windows.tar.lzma
- You should end up with OpenSSL files extracted in
C:\ruby\openssl
.
How to do it…
Once you have installed Redmine and its prerequisites, as explained in this recipe, proceed by installing the Puma server by typing the following:
gem install puma -- --with-opt-dir=c:\ruby\openssl
Testing Puma
This recipe assumes that your Redmine is installed, as explained in the, Installation on Windows servers recipe.
Run the following command from Redmine's directory in the command prompt:
puma -e production -p 3000
You should get a screen that looks like the following:
Navigating to http://127.0.0.1:3000
on your browser should open Redmine screen.
Configuring Puma to start with Windows
To have your Puma server started automatically with Windows, perform the following steps:
- Create a file,
pumastart.bat
, inC:\ruby
with the following contents:cd C:\redmine start /min puma -e production -p 3000 -t 8:32
- Then go to Server Manager | Tools | Task Scheduler | Create a Task.
- Check the Run whether user is logged or not, Run with highest privileges, and Hidden checkboxes.
- Then in Actions, go to New | Start a program and find
pumastart.bat
. - On the Triggers tab, click New and choose Begin the task: At startup (located in the top dropdown).
Configuring IIS
You should add an IIS role to your server and install the following two add-ons to IIS. You can install them directly from the Microsoft website.
You can get the URL Rewrite from http://www.iis.net/download/URLRewrite and the reverse proxy from http://www.iis.net/download/ApplicationRequestRouting.
- Open IIS Manager.
- Navigate to the website that you want to use as a Redmine proxy
- Click the URL Rewrite icon.
- Right-click inbound rules list.
- Select Add Rule and choose Reverse proxy.
- Add an Inbound rule with the following:
127.0.0.1:3000.
If your Puma server runs after clicking OK, you should be able to type http://localhost
or whatever your server name is and you will get the Redmine welcome screen.
How it works…
At first, we needed some prerequisites to install Puma because the gem
to install Puma compiles it on your machine, and it requires proper OpenSSL library headers and binaries to compile. This is the reason why OpenSSL and dev tools are required. Then, the Puma installation is tested just by typing puma -e production -p 3000.
To ensure that Puma starts after the Windows server restarts, Task Scheduler is used, and it schedules Puma to start on boot through a BAT file. In a bat file, command –t 8,32
tells Puma to start with a minimum of 8, and a maximum of 32 threads. You can adjust these values to fit your configuration. After this, we installed two Microsoft original modules to the IIS server and added a reverse proxy rule to forward all requests to 127.0.0.1:3000
where the Puma server is listening. We used the default IIS site, but this rule works with any or multiple IIS sites.
There's more…
This recipe can be easily adopted to use Puma behind Nginx or Apache on both Windows and Linux systems. Also Thin or Unicorn can be used instead of Puma.
See also
Check out the Puma website for updates, additional configurations and fine-tuning: