Rails 4 on IIS 8 with HTTP Platform Handler?

2019-04-30 11:14发布

Does anyone have experience with Microsoft's HTTP Platform Handler IIS extension yet? I'm following this great tutorial written a couple months ago and I've got Ruby on Rails installed:

C:\> ruby -v
ruby 2.1.5p273 (2014-11-13 revision 48405) [i386-mingw32]

C:\> rails -v
Rails 4.1.2

Rails starts and runs fine at port 3000 from a prompt:

C:\> rails s
=> Booting WEBrick
=> Rails 4.2.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2015-05-01 02:42:49] INFO WEBrick 1.3.1
[2015-05-01 02:42:49] INFO ruby 2.1.5 (2014-11-13) [i386-mingw32]
[2015-05-01 02:42:49] INFO WEBrick::HTTPServer#start: pid=9448 port=3000

This is great, but whenever I try to browse localhost/app (instead of localhost:3000), I get the dreaded "We're sorry, but something went wrong."

Here is my app's web.config file for IIS:

<?xml version="1.0"?>
<configuration>
    <system.webServer>      
      <handlers>
        <add
          name="httpplatformhandler"
          path="*"
          verb="*"
          modules="httpPlatformHandler"
          resourceType="Unspecified"
          requireAccess="Script" />
      </handlers>
      <httpPlatform
        stdoutLogEnabled="true"
        stdoutLogFile="rails.log"
        startupTimeLimit="200"
        processPath="c:\RailsInstaller\Ruby2.1.0\bin\ruby.exe"
        arguments="
          &quot;C:\Program Files\Windows Server\Bin\WebApps\Site\app\bin\rails&quot; server
          -p %HTTP_PLATFORM_PORT%
          -b 127.0.0.1">
      </httpPlatform>
    </system.webServer>
</configuration>

Event Viewer shows the HTTP Platform Handler initializing Ruby properly:

Process '10760' started successfully and is listening on port '2032'.

And Process Explorer shows w3wp.exe is running Ruby with the expected arguments:

ruby.exe 10760 c:\RailsInstaller\Ruby2.1.0\bin\ruby.exe "C:\Program Files\Windows Server\Bin\WebApps\Site\app\bin\rails" server -p 2032 -b 127.0.0.1

I can also see Rails is working from the rails.log file that HTTP Platform Handler generates:

=> Booting WEBrick
=> Rails 4.2.1 application starting in development on http://127.0.0.1:2032
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2015-05-02 12:23:44] INFO  WEBrick 1.3.1
[2015-05-02 12:23:44] INFO  ruby 2.1.5 (2014-11-13) [i386-mingw32]
[2015-05-02 12:23:45] INFO  WEBrick::HTTPServer#start: pid=10760 port=2032

Started GET "/app/" for [::1]:60449 at 2015-05-02 12:23:48 -0600

But I'm getting a 500 error and I can't figure out why. Here is the IIS log:

#Software: Microsoft Internet Information Services 8.5
#Version: 1.0
#Date: 2015-05-02 18:23:49
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken
2015-05-02 18:23:49 ::1 GET /app/ - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+WOW64;+Trident/7.0;+rv:11.0)+like+Gecko - 500 0 0 146996

So there is the 500.0 error. Referencing this, I see that means a Module or ISAPI error occurred. But that's not super helpful, so I enabled Failed Request Tracing and here are the contents of that log:

-MODULE_SET_RESPONSE_ERROR_STATUS
ModuleName httpPlatformHandler
Notification EXECUTE_REQUEST_HANDLER
HttpStatus 500
HttpReason Internal Server Error
HttpSubStatus 0
ErrorCode The operation completed successfully.
          (0x0)
ConfigExceptionInfo

I've already run rake db:migrate, and I also copied sqlite3.exe, sqlite3.def, and sqlite3.dll to system32. Is there anywhere else I can look to find out what's causing this 500 error?

0条回答
登录 后发表回答