Windows 上的 Apache 上的 Rails - HOWTO

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8095070/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 18:27:12  来源:igfitidea点击:

Rails on Apache on Windows - HOWTO

ruby-on-railswindowsapache

提问by zmilojko

This question has not been asked since Rail 3.0 came out (or I cannot find it):

这个问题自从 Rail 3.0 出来后就没有人问过(或者我找不到):

How to run Rails 3+ application on Apache on Windows (WAMP)? Is Mongrel the best option? Sounds not optimal to me to have Apache as a proxy and then another server. Passenger does not exist on Windows.

如何在 Windows (WAMP) 上的 Apache 上运行 Rails 3+ 应用程序?Mongrel 是最好的选择吗?对我来说,让 Apache 作为代理然后是另一台服务器听起来不是最佳选择。Windows 上不存在乘客。

What I hope to get from your is a link to a magical installation package and a snippet from the httpd.conf file that would divert one to a rails application.

我希望从你那里得到一个神奇的安装包的链接和一个来自 httpd.conf 文件的片段,它将把一个人转移到一个 rails 应用程序。

采纳答案by nathanvda

The advantage of using apache (or nginx) as a proxy is that it can load-balance between different mongrel (or thin) instances. So you would have to start three mongrel instances (services) and configure apache to proxy those.

使用 apache(或 nginx)作为代理的优势在于它可以在不同的 mongrel(或瘦)实例之间进行负载平衡。因此,您必须启动三个杂种实例(服务)并配置 apache 来代理它们。

Configuring apache to different mongrel processes is pretty straightforward, can be found all over the internet. Here is an example of a httpd-vhosts.conf(replace yourapplicationby your actual application/domain and root-folder):

将 apache 配置为不同的 mongrel 进程非常简单,可以在互联网上找到。这是一个示例httpd-vhosts.conf(替换yourapplication为您的实际应用程序/域和根文件夹):

<VirtualHost *:80>
    #ServerName 10.200.65.35
    #ServerAlias 10.200.65.35
    ServerName yourapplication.com

    DocumentRoot d:/yourapplication/current/

    <Directory c:/yourapplication/current/public/ >
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Order allow,deny
      allow from all
    </Directory>


     # On active les proxy qui sont par défaut désactivés
    <Proxy *>
        Order allow,deny
        Allow from all
    </Proxy>
    <Proxy balancer://mongrel_cluster>
        BalancerMember http://127.0.0.1:4000
        BalancerMember http://127.0.0.1:4001
        BalancerMember http://127.0.0.1:4002
    </Proxy>

    ProxyPass / Balancer://mongrel_cluster/
    ProxyPassReverse / balancer://mongrel_cluster/
    #ProxyReserveHost on


    #log files
    ErrorLog "/Program Files/Apache Software Foundation/Apache2.2/logs/yourapplication_error.log"
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn
    CustomLog "/Program Files/Apache Software Foundation/Apache2.2/logs/yourapplication_access.log" combined

    #Rewrite stuff
    RewriteEngine On

    # Rewrite index to check for static
    RewriteRule ^/$ /index.html [QSA] 

    # Rewrite to check for Rails cached page
    RewriteRule ^([^.]+)$ .html [QSA]

    # Redirect all non-static requests to cluster
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
    RewriteRule ^/(.*)$ balancer://mongrel_cluster%{REQUEST_URI} [P,QSA,L]
</VirtualHost>

Another, very promising alternative to deploy on windows is using TorqueBox. TorqueBox is JBoss/Jruby based solution, and thus platform independent. In benchmarksit is shown that TorqueBox performs incredibly well, and actually anybody should seriously consider switching to it.

在 Windows 上部署的另一个非常有前途的替代方案是使用TorqueBox。TorqueBox 是基于 JBoss/Jruby 的解决方案,因此与平台无关。在基准测试中,TorqueBox 表现得非常好,实际上任何人都应该认真考虑改用它。

Hope this helps.

希望这可以帮助。

回答by aviemet

I realize this is very old question, but I've just found a very easy solution which doesn't involve installing any new software. It only requires a few more flags in httpd.conf. It's detailed in this article on editrocket.com:

我意识到这是一个很老的问题,但我刚刚找到了一个非常简单的解决方案,它不涉及安装任何新软件。它只需要在 httpd.conf 中添加几个标志。editrocket.com 上的这篇文章对此进行了详细说明:

http://editrocket.com/articles/ruby_apache_windows.html

http://editrocket.com/articles/ruby_apache_windows.html

回答by reves

How about InstantRails have you tried it? http://rubyforge.org/projects/instantrails/

你试过 InstantRails 怎么样?http://rubyforge.org/projects/instantrails/

Instant Rails is a one-stop Rails runtime solution containing Ruby, Rails, Apache, and MySQL, all pre-configured and ready to run. No installer, you simply drop it into the directory of your choice and run it. It does not modify your system environment.

Instant Rails 是一个一站式的 Rails 运行时解决方案,包含 Ruby、Rails、Apache 和 MySQL,所有这些都已预先配置并准备好运行。无需安装程序,您只需将其放入您选择的目录中并运行即可。它不会修改您的系统环境。

What about trying a virtual machine like Vagrant: http://vagrantup.com/docs/getting-started/index.html

尝试像 Vagrant 这样的虚拟机怎么样:http: //vagrantup.com/docs/getting-started/index.html

Or perhaps JRubyStack.

或者也许是 JRubyStack。

As far as I know, the only way to deploy rails in windows is using apache + mongrel. Good luck!

据我所知,在 Windows 中部署 rails 的唯一方法是使用 apache + mongrel。祝你好运!