Does anyone have clear instruction for setting up jRuby to work with IIS.
有没有人有明确的说明设置jRuby与IIS一起工作。
Edit:
What I'm looking for is step by step instructions for getting a Ruby on Rails application working on Windows using IIS and jRuby. The reason being is because I can't find anything other then "use Linux" when asking the question out in the wild. For most people Windows is the primary development and deployment environment so using a Linux based server is out of the question. Also IIS is included with Windows and provide superior integration with Active Directory so using Apache is out of the question also.
我正在寻找的是使用IIS和jRuby在Windows上运行Ruby on Rails应用程序的分步说明。原因是因为我在野外提出问题时找不到其他任何“使用Linux”。对于大多数人来说,Windows是主要的开发和部署环境,因此使用基于Linux的服务器是不可能的。此外,IIS还包含在Windows中,并提供与Active Directory的卓越集成,因此使用Apache也是不可能的。
Last thing is using war files is a nightmare, please include instructions on how to deploy a rails apps by just copying the files or anything other then using war files.
最后一件事是使用war文件是一场噩梦,请包括如何通过复制文件或其他任何使用war文件来部署rails应用程序的说明。
2 个解决方案
#1
10
Is it actually just a Rails app you want to deploy on IIS, or must it be JRuby? If it's just Ruby on Rails rather than JRuby, then here is your step-by-step guide. But if it's JRuby you want to get working with IIS, look no further. Below are the steps I followed; my environment is IIS7 on Windows 7 RC, Java 1.6.0_13.
它实际上只是您想要在IIS上部署的Rails应用程序,还是必须是JRuby?如果它只是Ruby on Rails而不是JRuby,那么这是您的分步指南。但是如果它是JRuby你想要使用IIS,那就别再看了。以下是我遵循的步骤;我的环境是Windows 7 RC,Java 1.6.0_13上的IIS7。
- First, I downloaded JRuby from
http://dist.codehaus.org/jruby/1.3.1/jruby-bin-1.3.1.tar.gz
. - Then I extracted the archive to
C:\JRuby
. - I set environment variable JRUBY_HOME to
c:\JRuby\jruby-1.3.1
. - I added
%JRUBY_HOME%\bin
to the path.
首先,我从http://dist.codehaus.org/jruby/1.3.1/jruby-bin-1.3.1.tar.gz下载了JRuby。
然后我将存档解压缩到C:\ JRuby。
我将环境变量JRUBY_HOME设置为c:\ JRuby \ jruby-1.3.1。
我在路径中添加了%JRUBY_HOME%\ bin。
I'll walk through the next steps with screen grabs interspersed.
我将穿过屏幕抓取穿插的后续步骤。
Let's run jruby to confirm that it was installed successfully:
让我们运行jruby以确认它已成功安装:
C:\Users\Vinay>jruby -v jruby 1.3.1 (ruby 1.8.6p287) (2009-06-15 2fd6c3d) (Java HotSpot(TM) Client VM 1. 6.0_13) [x86-java]
OK so far. Let's use JRuby to install Rails:
好到目前为止。我们使用JRuby来安装Rails:
C:\Users\Vinay>gem install json-jruby C:\Users\Vinay>gem install rails --no-rdoc JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Successfully installed activerecord-2.3.3 Successfully installed rack-1.0.0 Successfully installed actionpack-2.3.3 Successfully installed actionmailer-2.3.3 Successfully installed activeresource-2.3.3 Successfully installed rails-2.3.3 6 gems installed Installing ri documentation for activerecord-2.3.3... Installing ri documentation for rack-1.0.0... Installing ri documentation for actionpack-2.3.3... Installing ri documentation for actionmailer-2.3.3... Installing ri documentation for activeresource-2.3.3... Installing ri documentation for rails-2.3.3...
Let's create a Rails app called jror
:
让我们创建一个名为jror的Rails应用程序:
C:\Users\Vinay\Projects>rails new jror create create app/controllers create app/helpers create app/models create app/views/layouts create config/environments create config/initializers create config/locales create db create doc create lib create lib/tasks create log create public/images create public/javascripts create public/stylesheets create script/performance create test/fixtures create test/functional create test/integration create test/performance create test/unit create vendor create vendor/plugins create tmp/sessions create tmp/sockets create tmp/cache create tmp/pids create Rakefile create README create app/controllers/application_controller.rb create app/helpers/application_helper.rb create config/database.yml create config/routes.rb create config/locales/en.yml create config/initializers/backtrace_silencers.rb create config/initializers/inflections.rb create config/initializers/mime_types.rb create config/initializers/new_rails_defaults.rb create config/initializers/session_store.rb create config/environment.rb create config/boot.rb create config/environments/production.rb create config/environments/development.rb create config/environments/test.rb create script/about create script/console create script/dbconsole create script/destroy create script/generate create script/runner create script/server create script/plugin create script/performance/benchmarker create script/performance/profiler create test/test_helper.rb create test/performance/browsing_test.rb create public/404.html create public/422.html create public/500.html create public/index.html create public/favicon.ico create public/robots.txt create public/images/rails.png create public/javascripts/prototype.js create public/javascripts/effects.js create public/javascripts/dragdrop.js create public/javascripts/controls.js create public/javascripts/application.js create doc/README_FOR_APP create log/server.log create log/production.log create log/development.log create log/test.log
Let's run WEBrick
to make sure everything's working as expected:
让我们运行WEBrick以确保一切正常运行:
C:\Users\Vinay\Projects\jror>jruby script/server => Booting WEBrick => Rails 2.3.3 application starting on http://0.0.0.0:3000 JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL => Call with -d to detach => Ctrl-C to shutdown server [2009-07-21 17:51:21] INFO WEBrick 1.3.1 [2009-07-21 17:51:21] INFO ruby 1.8.6 (2009-06-15) [java] [2009-07-21 17:51:21] INFO WEBrick::HTTPServer#start: pid=2440 port=3000
Navigate to http://localhost:3000/
and confirm that your Rails application appears.
导航到http:// localhost:3000 /并确认您的Rails应用程序出现。
Sure enough, there it is.
果然,就是这样。
The next thing is to set up a mechanism whereby selected requests made to IIS are proxied to JRuby. To do this, an URL rewriter/reverse proxy is needed. I used ISAPI Rewrite 3 for this. You may choose to use a different tool (for example, Microsoft ISA). ISAPI Rewrite 3 is good value at $99 per server, and comes with a 45-day trial period.
接下来要建立一种机制,将对IIS发出的选定请求代理到JRuby。为此,需要URL重写器/反向代理。我为此使用了ISAPI Rewrite 3。您可以选择使用其他工具(例如,Microsoft ISA)。 ISAPI Rewrite 3的价值很高,每台服务器99美元,并且有45天的试用期。
For ISAPI Rewrite 3, I set up the httpd.conf
configuration file as follows:
对于ISAPI Rewrite 3,我设置了httpd.conf配置文件,如下所示:
RewriteEngine on RewriteBase / RewriteLog "C:\temp\rewrite.log" RewriteLogLevel 9 RewriteProxy jror/(.*) http://localhost:3000/$1
This proxies URLs of the form
这代理了表单的URL
http://localhost/jror/abc123
to
http://localhost:3000/abc123
So now, we can navigate to http://localhost/jror/
and see the request served by JRuby but through IIS:
现在,我们可以导航到http:// localhost / jror /并查看JRuby提供的请求,但是通过IIS:
And guess what: no wars! Any changes to your Rails app should come through directly.
猜猜看:没有战争!您的Rails应用程序的任何更改都应该直接进行。
Here's a screenshot of my Firebug console showing the response headers for that page:
这是我的Firebug控制台的屏幕截图,显示该页面的响应标头:
Of course this is more of a development setup than a production one - but for production use you will probably need to use a production-ready appserver such as Glassfish, which will entail use of those pesky wars ;-)
当然,这更像是一个开发设置而不是生产设置 - 但是对于生产用途,您可能需要使用生产就绪的应用程序服务器,例如Glassfish,这将需要使用那些讨厌的战争;-)
If and when you do want to deploy to a Java appserver using wars, you can use Warbler for easy packaging of your app into a war.
如果您确实希望使用战争部署到Java应用程序服务器,则可以使用Warbler轻松将应用程序打包成战争。
To run on Glassfish V3, some additional steps are required. The quickest way to deploy and run your Rails applications is to use the GlassFish gem, which consists of only the GlassFish v3 kernel (Grizzly
) and some utilities, so giving a minimum-bloat setup. Let's install the gem:
要在Glassfish V3上运行,需要执行一些其他步骤。部署和运行Rails应用程序的最快方法是使用GlassFish gem,它只包含GlassFish v3内核(Grizzly)和一些实用程序,因此提供最小膨胀设置。让我们安装gem:
C:\Users\Vinay\Projects\jror>gem install glassfish JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Successfully installed glassfish-0.9.5-universal-java 1 gem installed Installing ri documentation for glassfish-0.9.5-universal-java... Installing RDoc documentation for glassfish-0.9.5-universal-java...
Run the Rails app on Glassfish:
在Glassfish上运行Rails应用程序:
C:\Users\Vinay\Projects>glassfish jror Starting GlassFish server at: 192.168.0.17:3000 in development environment... Writing log messages to: jror/log/development.log. Press Ctrl+C to stop.
As you can see, you're running on Glassfish but still no wars are required! No changes are needed on the IIS side, other than (in httpd.conf
in my setup) changing the proxy to point to the IP address and port used by the Glassfish server. If you want to go the whole hog and install the full Glassfish server and run Rails apps on it, you may as well follow these instructions from the Glassfish team. They cover installing and running the Glassfish, server, deploying and undeploying Rails applications and running the applications in production mode.
如您所见,您在Glassfish上运行,但仍然不需要战争!除了(在我的设置中的httpd.conf中)将代理更改为指向Glassfish服务器使用的IP地址和端口之外,IIS端不需要进行任何更改。如果您想要全部使用并安装完整的Glassfish服务器并在其上运行Rails应用程序,您也可以按照Glassfish团队的这些说明进行操作。它们包括安装和运行Glassfish,服务器,部署和取消部署Rails应用程序以及在生产模式下运行应用程序。
Here's what you need to create war files for the full Glassfish server.
以下是为完整的Glassfish服务器创建war文件所需的内容。
Install Warbler:
C:\Users\Vinay\Projects>gem install warbler JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Successfully installed warbler-0.9.13 1 gem installed Installing ri documentation for warbler-0.9.13... Installing RDoc documentation for warbler-0.9.13...
Run Warbler:
C:\Users\Vinay\Projects\jror>warble mkdir -p tmp/war/WEB-INF/gems/specifications cp C:/JRuby/jruby-1.3.1/lib/ruby/gems/1.8/specifications/rails-2.3.3.gemspec tm /war/WEB-INF/gems/specifications/rails-2.3.3.gemspec mkdir -p tmp/war/WEB-INF/gems/gems cp C:/JRuby/jruby-1.3.1/lib/ruby/gems/1.8/specifications/rake-0.8.7.gemspec tmp war/WEB-INF/gems/specifications/rake-0.8.7.gemspec cp C:/JRuby/jruby-1.3.1/lib/ruby/gems/1.8/specifications/activesupport-2.3.3.ge spec tmp/war/WEB-INF/gems/specifications/activesupport-2.3.3.gemspec cp C:/JRuby/jruby-1.3.1/lib/ruby/gems/1.8/specifications/activerecord-2.3.3.gem pec tmp/war/WEB-INF/gems/specifications/activerecord-2.3.3.gemspec cp C:/JRuby/jruby-1.3.1/lib/ruby/gems/1.8/specifications/actionpack-2.3.3.gemsp c tmp/war/WEB-INF/gems/specifications/actionpack-2.3.3.gemspec cp C:/JRuby/jruby-1.3.1/lib/ruby/gems/1.8/specifications/rack-1.0.0.gemspec tmp war/WEB-INF/gems/specifications/rack-1.0.0.gemspec cp C:/JRuby/jruby-1.3.1/lib/ruby/gems/1.8/specifications/actionmailer-2.3.3.gem pec tmp/war/WEB-INF/gems/specifications/actionmailer-2.3.3.gemspec cp C:/JRuby/jruby-1.3.1/lib/ruby/gems/1.8/specifications/activeresource-2.3.3.g mspec tmp/war/WEB-INF/gems/specifications/activeresource-2.3.3.gemspec mkdir -p tmp/war/WEB-INF/app mkdir -p tmp/war/WEB-INF/config mkdir -p tmp/war/WEB-INF/lib mkdir -p tmp/war/WEB-INF/log mkdir -p tmp/war/WEB-INF/vendor mkdir -p tmp/war/WEB-INF/tmp mkdir -p tmp/war/WEB-INF/app/controllers mkdir -p tmp/war/WEB-INF/app/helpers mkdir -p tmp/war/WEB-INF/app/models mkdir -p tmp/war/WEB-INF/app/views cp app/controllers/application_controller.rb tmp/war/WEB-INF/app/controllers/ap lication_controller.rb cp app/helpers/application_helper.rb tmp/war/WEB-INF/app/helpers/application_he per.rb mkdir -p tmp/war/WEB-INF/app/views/layouts cp config/boot.rb tmp/war/WEB-INF/config/boot.rb cp config/database.yml tmp/war/WEB-INF/config/database.yml cp config/environment.rb tmp/war/WEB-INF/config/environment.rb mkdir -p tmp/war/WEB-INF/config/environments mkdir -p tmp/war/WEB-INF/config/initializers mkdir -p tmp/war/WEB-INF/config/locales cp config/routes.rb tmp/war/WEB-INF/config/routes.rb cp config/environments/development.rb tmp/war/WEB-INF/config/environments/devel pment.rb cp config/environments/production.rb tmp/war/WEB-INF/config/environments/produc ion.rb cp config/environments/test.rb tmp/war/WEB-INF/config/environments/test.rb cp config/initializers/backtrace_silencers.rb tmp/war/WEB-INF/config/initialize s/backtrace_silencers.rb cp config/initializers/inflections.rb tmp/war/WEB-INF/config/initializers/infle tions.rb cp config/initializers/mime_types.rb tmp/war/WEB-INF/config/initializers/mime_t pes.rb cp config/initializers/new_rails_defaults.rb tmp/war/WEB-INF/config/initializer /new_rails_defaults.rb cp config/initializers/session_store.rb tmp/war/WEB-INF/config/initializers/ses ion_store.rb cp config/locales/en.yml tmp/war/WEB-INF/config/locales/en.yml mkdir -p tmp/war/WEB-INF/lib/tasks mkdir -p tmp/war/WEB-INF/vendor/plugins mkdir -p tmp/war/WEB-INF/tmp/cache mkdir -p tmp/war/WEB-INF/tmp/pids mkdir -p tmp/war/WEB-INF/tmp/sessions mkdir -p tmp/war/WEB-INF/tmp/sockets cp C:/JRuby/jruby-1.3.1/lib/ruby/gems/1.8/gems/warbler-0.9.13/lib/jruby-complet -1.3.0RC1.jar tmp/war/WEB-INF/lib/jruby-complete-1.3.0RC1.jar cp C:/JRuby/jruby-1.3.1/lib/ruby/gems/1.8/gems/warbler-0.9.13/lib/jruby-complet -1.3.0RC1.jar tmp/war/WEB-INF/lib/jruby-complete-1.3.0RC1.jar cp C:/JRuby/jruby-1.3.1/lib/ruby/gems/1.8/gems/warbler-0.9.13/lib/jruby-rack-0. .4.jar tmp/war/WEB-INF/lib/jruby-rack-0.9.4.jar cp C:/JRuby/jruby-1.3.1/lib/ruby/gems/1.8/gems/warbler-0.9.13/lib/jruby-rack-0. .4.jar tmp/war/WEB-INF/lib/jruby-rack-0.9.4.jar cp public/404.html tmp/war/404.html cp public/422.html tmp/war/422.html cp public/500.html tmp/war/500.html cp public/favicon.ico tmp/war/favicon.ico mkdir -p tmp/war/images cp public/index.html tmp/war/index.html mkdir -p tmp/war/javascripts cp public/robots.txt tmp/war/robots.txt mkdir -p tmp/war/stylesheets cp public/images/rails.png tmp/war/images/rails.png cp public/javascripts/application.js tmp/war/javascripts/application.js cp public/javascripts/controls.js tmp/war/javascripts/controls.js cp public/javascripts/dragdrop.js tmp/war/javascripts/dragdrop.js cp public/javascripts/effects.js tmp/war/javascripts/effects.js cp public/javascripts/prototype.js tmp/war/javascripts/prototype.js mkdir -p tmp/war/WEB-INF jar cf jror.war -C tmp/war . C:\Users\Vinay\Projects\jror>dir jror.war Volume in drive C has no label. Volume Serial Number is 0C8D-1418 Directory of C:\Users\Vinay\Projects\jror 22/07/2009 15:55 13,180,634 jror.war 1 File(s) 13,180,634 bytes 0 Dir(s) 7,730,462,720 bytes free
Phew!
#2
5
You need first to install Tomcat. See this how-to for setting up Tomcat together with IIS.
您首先需要安装Tomcat。请参阅此方法,以便与IIS一起设置Tomcat。
With JRuby you are going to build WAR files. Just drop these into Tomcat's webapps folder and you are ready to go.
使用JRuby,您将构建WAR文件。只需将它们放入Tomcat的webapps文件夹中即可开始使用。
Update: Ok, you need to integrate two technologies that weren't meant to be used together: IIS and JRuby. The good thing is that JRuby is both Java and Ruby and you can use the best from both worlds. Ruby is more productive and fun to code with, but Java is better for deployment (especially when need to do so with IIS). So my advice still holds. Create a war file, install Tomcat and deploy the war file there. Deploying the war file is as easy as copying it in the webapps folder. These are the steps you need to follow:
更新:好的,您需要集成两个不能一起使用的技术:IIS和JRuby。好的是JRuby既是Java又是Ruby,你可以使用两者中最好的东西。 Ruby的编写效率更高,更有趣,但Java更适合部署(特别是在需要使用IIS时)。所以我的建议仍然存在。创建一个war文件,安装Tomcat并在那里部署war文件。部署war文件就像在webapps文件夹中复制一样简单。这些是您需要遵循的步骤:
- Install Tomcat
- Integrate Tomcat with IIS using the ISAPI plug-in (I can help if you need more info on this)
- Create a WAR file (Netbeans IDE can do that for you)
- Copy the WAR file to the webapps folder of Tomcat
使用ISAPI插件将Tomcat与IIS集成(如果您需要更多信息,我可以提供帮助)
创建一个WAR文件(Netbeans IDE可以为您做到这一点)
将WAR文件复制到Tomcat的webapps文件夹
If you still do not want to use WAR files have a look at this blog spot. It describes how you can run RoR with IIS. I believe that for JRuby the procedure would be just the same. Anyway, a CGI approach is the only way if you want to avoid WAR files.
如果您仍然不想使用WAR文件,请查看此博客点。它描述了如何使用IIS运行RoR。我相信对JRuby来说,程序也是一样的。无论如何,如果你想避免使用WAR文件,那么CGI方法是唯一的方法。
#1
10
Is it actually just a Rails app you want to deploy on IIS, or must it be JRuby? If it's just Ruby on Rails rather than JRuby, then here is your step-by-step guide. But if it's JRuby you want to get working with IIS, look no further. Below are the steps I followed; my environment is IIS7 on Windows 7 RC, Java 1.6.0_13.
它实际上只是您想要在IIS上部署的Rails应用程序,还是必须是JRuby?如果它只是Ruby on Rails而不是JRuby,那么这是您的分步指南。但是如果它是JRuby你想要使用IIS,那就别再看了。以下是我遵循的步骤;我的环境是Windows 7 RC,Java 1.6.0_13上的IIS7。
- First, I downloaded JRuby from
http://dist.codehaus.org/jruby/1.3.1/jruby-bin-1.3.1.tar.gz
. - Then I extracted the archive to
C:\JRuby
. - I set environment variable JRUBY_HOME to
c:\JRuby\jruby-1.3.1
. - I added
%JRUBY_HOME%\bin
to the path.
首先,我从http://dist.codehaus.org/jruby/1.3.1/jruby-bin-1.3.1.tar.gz下载了JRuby。
然后我将存档解压缩到C:\ JRuby。
我将环境变量JRUBY_HOME设置为c:\ JRuby \ jruby-1.3.1。
我在路径中添加了%JRUBY_HOME%\ bin。
I'll walk through the next steps with screen grabs interspersed.
我将穿过屏幕抓取穿插的后续步骤。
Let's run jruby to confirm that it was installed successfully:
让我们运行jruby以确认它已成功安装:
C:\Users\Vinay>jruby -v jruby 1.3.1 (ruby 1.8.6p287) (2009-06-15 2fd6c3d) (Java HotSpot(TM) Client VM 1. 6.0_13) [x86-java]
OK so far. Let's use JRuby to install Rails:
好到目前为止。我们使用JRuby来安装Rails:
C:\Users\Vinay>gem install json-jruby C:\Users\Vinay>gem install rails --no-rdoc JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Successfully installed activerecord-2.3.3 Successfully installed rack-1.0.0 Successfully installed actionpack-2.3.3 Successfully installed actionmailer-2.3.3 Successfully installed activeresource-2.3.3 Successfully installed rails-2.3.3 6 gems installed Installing ri documentation for activerecord-2.3.3... Installing ri documentation for rack-1.0.0... Installing ri documentation for actionpack-2.3.3... Installing ri documentation for actionmailer-2.3.3... Installing ri documentation for activeresource-2.3.3... Installing ri documentation for rails-2.3.3...
Let's create a Rails app called jror
:
让我们创建一个名为jror的Rails应用程序:
C:\Users\Vinay\Projects>rails new jror create create app/controllers create app/helpers create app/models create app/views/layouts create config/environments create config/initializers create config/locales create db create doc create lib create lib/tasks create log create public/images create public/javascripts create public/stylesheets create script/performance create test/fixtures create test/functional create test/integration create test/performance create test/unit create vendor create vendor/plugins create tmp/sessions create tmp/sockets create tmp/cache create tmp/pids create Rakefile create README create app/controllers/application_controller.rb create app/helpers/application_helper.rb create config/database.yml create config/routes.rb create config/locales/en.yml create config/initializers/backtrace_silencers.rb create config/initializers/inflections.rb create config/initializers/mime_types.rb create config/initializers/new_rails_defaults.rb create config/initializers/session_store.rb create config/environment.rb create config/boot.rb create config/environments/production.rb create config/environments/development.rb create config/environments/test.rb create script/about create script/console create script/dbconsole create script/destroy create script/generate create script/runner create script/server create script/plugin create script/performance/benchmarker create script/performance/profiler create test/test_helper.rb create test/performance/browsing_test.rb create public/404.html create public/422.html create public/500.html create public/index.html create public/favicon.ico create public/robots.txt create public/images/rails.png create public/javascripts/prototype.js create public/javascripts/effects.js create public/javascripts/dragdrop.js create public/javascripts/controls.js create public/javascripts/application.js create doc/README_FOR_APP create log/server.log create log/production.log create log/development.log create log/test.log
Let's run WEBrick
to make sure everything's working as expected:
让我们运行WEBrick以确保一切正常运行:
C:\Users\Vinay\Projects\jror>jruby script/server => Booting WEBrick => Rails 2.3.3 application starting on http://0.0.0.0:3000 JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL => Call with -d to detach => Ctrl-C to shutdown server [2009-07-21 17:51:21] INFO WEBrick 1.3.1 [2009-07-21 17:51:21] INFO ruby 1.8.6 (2009-06-15) [java] [2009-07-21 17:51:21] INFO WEBrick::HTTPServer#start: pid=2440 port=3000
Navigate to http://localhost:3000/
and confirm that your Rails application appears.
导航到http:// localhost:3000 /并确认您的Rails应用程序出现。
Sure enough, there it is.
果然,就是这样。
The next thing is to set up a mechanism whereby selected requests made to IIS are proxied to JRuby. To do this, an URL rewriter/reverse proxy is needed. I used ISAPI Rewrite 3 for this. You may choose to use a different tool (for example, Microsoft ISA). ISAPI Rewrite 3 is good value at $99 per server, and comes with a 45-day trial period.
接下来要建立一种机制,将对IIS发出的选定请求代理到JRuby。为此,需要URL重写器/反向代理。我为此使用了ISAPI Rewrite 3。您可以选择使用其他工具(例如,Microsoft ISA)。 ISAPI Rewrite 3的价值很高,每台服务器99美元,并且有45天的试用期。
For ISAPI Rewrite 3, I set up the httpd.conf
configuration file as follows:
对于ISAPI Rewrite 3,我设置了httpd.conf配置文件,如下所示:
RewriteEngine on RewriteBase / RewriteLog "C:\temp\rewrite.log" RewriteLogLevel 9 RewriteProxy jror/(.*) http://localhost:3000/$1
This proxies URLs of the form
这代理了表单的URL
http://localhost/jror/abc123
to
http://localhost:3000/abc123
So now, we can navigate to http://localhost/jror/
and see the request served by JRuby but through IIS:
现在,我们可以导航到http:// localhost / jror /并查看JRuby提供的请求,但是通过IIS:
And guess what: no wars! Any changes to your Rails app should come through directly.
猜猜看:没有战争!您的Rails应用程序的任何更改都应该直接进行。
Here's a screenshot of my Firebug console showing the response headers for that page:
这是我的Firebug控制台的屏幕截图,显示该页面的响应标头:
Of course this is more of a development setup than a production one - but for production use you will probably need to use a production-ready appserver such as Glassfish, which will entail use of those pesky wars ;-)
当然,这更像是一个开发设置而不是生产设置 - 但是对于生产用途,您可能需要使用生产就绪的应用程序服务器,例如Glassfish,这将需要使用那些讨厌的战争;-)
If and when you do want to deploy to a Java appserver using wars, you can use Warbler for easy packaging of your app into a war.
如果您确实希望使用战争部署到Java应用程序服务器,则可以使用Warbler轻松将应用程序打包成战争。
To run on Glassfish V3, some additional steps are required. The quickest way to deploy and run your Rails applications is to use the GlassFish gem, which consists of only the GlassFish v3 kernel (Grizzly
) and some utilities, so giving a minimum-bloat setup. Let's install the gem:
要在Glassfish V3上运行,需要执行一些其他步骤。部署和运行Rails应用程序的最快方法是使用GlassFish gem,它只包含GlassFish v3内核(Grizzly)和一些实用程序,因此提供最小膨胀设置。让我们安装gem:
C:\Users\Vinay\Projects\jror>gem install glassfish JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Successfully installed glassfish-0.9.5-universal-java 1 gem installed Installing ri documentation for glassfish-0.9.5-universal-java... Installing RDoc documentation for glassfish-0.9.5-universal-java...
Run the Rails app on Glassfish:
在Glassfish上运行Rails应用程序:
C:\Users\Vinay\Projects>glassfish jror Starting GlassFish server at: 192.168.0.17:3000 in development environment... Writing log messages to: jror/log/development.log. Press Ctrl+C to stop.
As you can see, you're running on Glassfish but still no wars are required! No changes are needed on the IIS side, other than (in httpd.conf
in my setup) changing the proxy to point to the IP address and port used by the Glassfish server. If you want to go the whole hog and install the full Glassfish server and run Rails apps on it, you may as well follow these instructions from the Glassfish team. They cover installing and running the Glassfish, server, deploying and undeploying Rails applications and running the applications in production mode.
如您所见,您在Glassfish上运行,但仍然不需要战争!除了(在我的设置中的httpd.conf中)将代理更改为指向Glassfish服务器使用的IP地址和端口之外,IIS端不需要进行任何更改。如果您想要全部使用并安装完整的Glassfish服务器并在其上运行Rails应用程序,您也可以按照Glassfish团队的这些说明进行操作。它们包括安装和运行Glassfish,服务器,部署和取消部署Rails应用程序以及在生产模式下运行应用程序。
Here's what you need to create war files for the full Glassfish server.
以下是为完整的Glassfish服务器创建war文件所需的内容。
Install Warbler:
C:\Users\Vinay\Projects>gem install warbler JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Successfully installed warbler-0.9.13 1 gem installed Installing ri documentation for warbler-0.9.13... Installing RDoc documentation for warbler-0.9.13...
Run Warbler:
C:\Users\Vinay\Projects\jror>warble mkdir -p tmp/war/WEB-INF/gems/specifications cp C:/JRuby/jruby-1.3.1/lib/ruby/gems/1.8/specifications/rails-2.3.3.gemspec tm /war/WEB-INF/gems/specifications/rails-2.3.3.gemspec mkdir -p tmp/war/WEB-INF/gems/gems cp C:/JRuby/jruby-1.3.1/lib/ruby/gems/1.8/specifications/rake-0.8.7.gemspec tmp war/WEB-INF/gems/specifications/rake-0.8.7.gemspec cp C:/JRuby/jruby-1.3.1/lib/ruby/gems/1.8/specifications/activesupport-2.3.3.ge spec tmp/war/WEB-INF/gems/specifications/activesupport-2.3.3.gemspec cp C:/JRuby/jruby-1.3.1/lib/ruby/gems/1.8/specifications/activerecord-2.3.3.gem pec tmp/war/WEB-INF/gems/specifications/activerecord-2.3.3.gemspec cp C:/JRuby/jruby-1.3.1/lib/ruby/gems/1.8/specifications/actionpack-2.3.3.gemsp c tmp/war/WEB-INF/gems/specifications/actionpack-2.3.3.gemspec cp C:/JRuby/jruby-1.3.1/lib/ruby/gems/1.8/specifications/rack-1.0.0.gemspec tmp war/WEB-INF/gems/specifications/rack-1.0.0.gemspec cp C:/JRuby/jruby-1.3.1/lib/ruby/gems/1.8/specifications/actionmailer-2.3.3.gem pec tmp/war/WEB-INF/gems/specifications/actionmailer-2.3.3.gemspec cp C:/JRuby/jruby-1.3.1/lib/ruby/gems/1.8/specifications/activeresource-2.3.3.g mspec tmp/war/WEB-INF/gems/specifications/activeresource-2.3.3.gemspec mkdir -p tmp/war/WEB-INF/app mkdir -p tmp/war/WEB-INF/config mkdir -p tmp/war/WEB-INF/lib mkdir -p tmp/war/WEB-INF/log mkdir -p tmp/war/WEB-INF/vendor mkdir -p tmp/war/WEB-INF/tmp mkdir -p tmp/war/WEB-INF/app/controllers mkdir -p tmp/war/WEB-INF/app/helpers mkdir -p tmp/war/WEB-INF/app/models mkdir -p tmp/war/WEB-INF/app/views cp app/controllers/application_controller.rb tmp/war/WEB-INF/app/controllers/ap lication_controller.rb cp app/helpers/application_helper.rb tmp/war/WEB-INF/app/helpers/application_he per.rb mkdir -p tmp/war/WEB-INF/app/views/layouts cp config/boot.rb tmp/war/WEB-INF/config/boot.rb cp config/database.yml tmp/war/WEB-INF/config/database.yml cp config/environment.rb tmp/war/WEB-INF/config/environment.rb mkdir -p tmp/war/WEB-INF/config/environments mkdir -p tmp/war/WEB-INF/config/initializers mkdir -p tmp/war/WEB-INF/config/locales cp config/routes.rb tmp/war/WEB-INF/config/routes.rb cp config/environments/development.rb tmp/war/WEB-INF/config/environments/devel pment.rb cp config/environments/production.rb tmp/war/WEB-INF/config/environments/produc ion.rb cp config/environments/test.rb tmp/war/WEB-INF/config/environments/test.rb cp config/initializers/backtrace_silencers.rb tmp/war/WEB-INF/config/initialize s/backtrace_silencers.rb cp config/initializers/inflections.rb tmp/war/WEB-INF/config/initializers/infle tions.rb cp config/initializers/mime_types.rb tmp/war/WEB-INF/config/initializers/mime_t pes.rb cp config/initializers/new_rails_defaults.rb tmp/war/WEB-INF/config/initializer /new_rails_defaults.rb cp config/initializers/session_store.rb tmp/war/WEB-INF/config/initializers/ses ion_store.rb cp config/locales/en.yml tmp/war/WEB-INF/config/locales/en.yml mkdir -p tmp/war/WEB-INF/lib/tasks mkdir -p tmp/war/WEB-INF/vendor/plugins mkdir -p tmp/war/WEB-INF/tmp/cache mkdir -p tmp/war/WEB-INF/tmp/pids mkdir -p tmp/war/WEB-INF/tmp/sessions mkdir -p tmp/war/WEB-INF/tmp/sockets cp C:/JRuby/jruby-1.3.1/lib/ruby/gems/1.8/gems/warbler-0.9.13/lib/jruby-complet -1.3.0RC1.jar tmp/war/WEB-INF/lib/jruby-complete-1.3.0RC1.jar cp C:/JRuby/jruby-1.3.1/lib/ruby/gems/1.8/gems/warbler-0.9.13/lib/jruby-complet -1.3.0RC1.jar tmp/war/WEB-INF/lib/jruby-complete-1.3.0RC1.jar cp C:/JRuby/jruby-1.3.1/lib/ruby/gems/1.8/gems/warbler-0.9.13/lib/jruby-rack-0. .4.jar tmp/war/WEB-INF/lib/jruby-rack-0.9.4.jar cp C:/JRuby/jruby-1.3.1/lib/ruby/gems/1.8/gems/warbler-0.9.13/lib/jruby-rack-0. .4.jar tmp/war/WEB-INF/lib/jruby-rack-0.9.4.jar cp public/404.html tmp/war/404.html cp public/422.html tmp/war/422.html cp public/500.html tmp/war/500.html cp public/favicon.ico tmp/war/favicon.ico mkdir -p tmp/war/images cp public/index.html tmp/war/index.html mkdir -p tmp/war/javascripts cp public/robots.txt tmp/war/robots.txt mkdir -p tmp/war/stylesheets cp public/images/rails.png tmp/war/images/rails.png cp public/javascripts/application.js tmp/war/javascripts/application.js cp public/javascripts/controls.js tmp/war/javascripts/controls.js cp public/javascripts/dragdrop.js tmp/war/javascripts/dragdrop.js cp public/javascripts/effects.js tmp/war/javascripts/effects.js cp public/javascripts/prototype.js tmp/war/javascripts/prototype.js mkdir -p tmp/war/WEB-INF jar cf jror.war -C tmp/war . C:\Users\Vinay\Projects\jror>dir jror.war Volume in drive C has no label. Volume Serial Number is 0C8D-1418 Directory of C:\Users\Vinay\Projects\jror 22/07/2009 15:55 13,180,634 jror.war 1 File(s) 13,180,634 bytes 0 Dir(s) 7,730,462,720 bytes free
Phew!
#2
5
You need first to install Tomcat. See this how-to for setting up Tomcat together with IIS.
您首先需要安装Tomcat。请参阅此方法,以便与IIS一起设置Tomcat。
With JRuby you are going to build WAR files. Just drop these into Tomcat's webapps folder and you are ready to go.
使用JRuby,您将构建WAR文件。只需将它们放入Tomcat的webapps文件夹中即可开始使用。
Update: Ok, you need to integrate two technologies that weren't meant to be used together: IIS and JRuby. The good thing is that JRuby is both Java and Ruby and you can use the best from both worlds. Ruby is more productive and fun to code with, but Java is better for deployment (especially when need to do so with IIS). So my advice still holds. Create a war file, install Tomcat and deploy the war file there. Deploying the war file is as easy as copying it in the webapps folder. These are the steps you need to follow:
更新:好的,您需要集成两个不能一起使用的技术:IIS和JRuby。好的是JRuby既是Java又是Ruby,你可以使用两者中最好的东西。 Ruby的编写效率更高,更有趣,但Java更适合部署(特别是在需要使用IIS时)。所以我的建议仍然存在。创建一个war文件,安装Tomcat并在那里部署war文件。部署war文件就像在webapps文件夹中复制一样简单。这些是您需要遵循的步骤:
- Install Tomcat
- Integrate Tomcat with IIS using the ISAPI plug-in (I can help if you need more info on this)
- Create a WAR file (Netbeans IDE can do that for you)
- Copy the WAR file to the webapps folder of Tomcat
使用ISAPI插件将Tomcat与IIS集成(如果您需要更多信息,我可以提供帮助)
创建一个WAR文件(Netbeans IDE可以为您做到这一点)
将WAR文件复制到Tomcat的webapps文件夹
If you still do not want to use WAR files have a look at this blog spot. It describes how you can run RoR with IIS. I believe that for JRuby the procedure would be just the same. Anyway, a CGI approach is the only way if you want to avoid WAR files.
如果您仍然不想使用WAR文件,请查看此博客点。它描述了如何使用IIS运行RoR。我相信对JRuby来说,程序也是一样的。无论如何,如果你想避免使用WAR文件,那么CGI方法是唯一的方法。