是否可以将Ruby on Rails与WampServer一起安装(并保留WampServer的Apache / MySQL安装)?

最佳答案

我在WampServer旁边安装了Ruby on Rails。这是操作方法:

将以下文本中的C:\wamp\替换为您自己的WampServer的安装存储库。

安装Ruby:

  • 下载Ruby。使用Windows 二进制版本,而不是“一键安装程序”,因为它包含我们不需要的MySQL和Apache。
  • 将zip提取到C:\wamp\ruby\
  • 在PATH环境变量中添加Ruby的bin存储库:
  • 右键单击“计算机/属性”。
  • 单击“高级系统设置”。
  • 高级选项卡/环境变量。
  • ;C:\wamp\ruby\bin附加到Path变量。

  • 安装DevKit:

    下载DevKit:
  • 将DevKit提取到c:\wamp\ruby\DevKit中。
  • cd /d c:\wamp\ruby\DevKit
  • ruby dk.rb init
  • - c:\wamp\ruby添加到config.yml的末尾。
  • ruby dk.rb install

  • 安装Rails和Mongrel服务器:
  • 打开命令行并输入:
    gem install rails
    
  • 通过打开C:\wamp\www\rails\的命令行并输入以下命令来创建您的第一个Rails应用程序:
    rails hello
    
  • 安装Mongrel服务器和Windows Mongrel服务,确保以管理员身份运行命令行:
    gem install mongrel and
    gem install mongrel_service
    
  • 为Rails应用程序安装Windows服务:
    mongrel_rails service::install -N ruby-hello -c c:\wamp\www\rails\hello -p 3001 -e development
    
  • 启动您的Mongrel服务:
    net start ruby-hello
    

  • 您现在可以通过http://localhost:3001/访问Rails应用程序。

    与Apache集成
  • 在httpd.conf中启用mod_proxy

    打开httpd.conf(c:\ wamp \ bin \ apache \ Apache2.x.x \ conf \ httpd.conf)并取消注释以下行:
    LoadModule proxy_module modules/mod_proxy.so
    
  • 将流量转发到Mongrel服务器。将以下文本添加到您的httpd.conf中(如果包含在httpd.conf中,则将其添加到Extra / httpd-vhosts.conf中):
    <VirtualHost *:80>
    ServerName hello.com
    ServerAlias *.hello.com
    ProxyPass / http://localhost:3001/
    ProxyPassReverse / http://localhost:3001
    </VirtualHost>
    
  • 将hello.com添加到您的主机文件。在记事本中打开c:\windows\system32\drivers\etc\hosts并添加以下行:
    127.0.0.1 www.hello.com hello.com
    

  • 现在,您可以转到http://www.hello.com,它将加载您的Rails应用程序。

    引用文献:
  • http://rubyinstaller.org/downloads
  • http://www.wampserver.com
  • http://www.ruby-lang.org
  • http://mongrel.rubyforge.orghttp://mongrel.rubyforge.org/wiki/Win32
  • 07-24 09:49
    查看更多