【发布时间】:2010-01-08 04:12:01
【问题描述】:
是否可以在 WampServer 旁边安装 Ruby on Rails(并保留 WampServer 的 Apache/MySQL 安装)?
【问题讨论】:
标签: ruby-on-rails installation wamp wampserver
是否可以在 WampServer 旁边安装 Ruby on Rails(并保留 WampServer 的 Apache/MySQL 安装)?
【问题讨论】:
标签: ruby-on-rails installation wamp wampserver
我在 WampServer 旁边安装了 Ruby on Rails。操作方法如下:
将以下文本中的C:\wamp\ 替换为您自己的 WampServer 的安装存储库。
安装 Ruby:
C:\wamp\ruby\。在您的 PATH 环境变量中添加 Ruby 的 bin 存储库:
;C:\wamp\ruby\bin 附加到 Path 变量中。安装 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-vhosts.conf,如果它包含在您的 httpd.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 应用程序。
参考资料:
【讨论】:
gem install rails 时出现此错误:缺少dll ssleay32.dll 和zlib.dll;关注alwaysthecritic.typepad.com/atc/2009/03/…,得到了 dll,现在缺少 readline.dll。
是的,有InstantRails
【讨论】:
这是假设您正在尝试设置开发环境,因为将 Windows 和/或 WAMP 用于生产服务器没有多大意义。
您可以使用Ruby installer 在 Windows 上相当轻松地安装 Ruby。还有one-click installer,其中包含许多库(尽管您可以稍后使用 rubygems 自己安装这些库)。
您是正确的,因为您将 Rails(和依赖项)安装为 gem。
现在,至于 Apache...我建议您保留 WAMP 安装,不要将其用于 Ruby/Rails。 Ruby 有一个名为 WEBrick 的内置 Web 服务器,还有另一个名为 Mongrel 的轻量级服务器(以 gem 的形式提供)。这些可以与 Apache 同时运行,Apache 服务 PHP 内容,Mongrel/WEBrick 服务 Rails。它们会在不同的端口上运行(Apache 在 80,Mongrel/WEBrick 默认在 3000),所以不应该有任何冲突。
这种方法有几个优点:
MySQL 与 Apache 是分开的,因此您的 Rails 应用程序将能够访问 MySQL 数据库,而不管哪个服务器为其内容提供服务。当然,您必须至少运行 MySQL 版本的 WAMP 才能使其工作。
【讨论】:
使用独立的 Ruby 服务器安装:a) http://railsinstaller.org/en b) http://www.helicontech.com/zoo/install.html c) https://bitnami.com/stack/ruby
或
1) 安装 WAMP(或其他)
2) 安装Ruby
3) 打开 ...wamp\bin\apache\apacheXXXX\conf\httpd.conf,然后搜索替换
Options Indexes FollowSymLinks
与
Options Indexes FollowSymLinks <strong>ExecCGI</strong>(或Options Indexes FollowSymLinks <strong>Includes ExecCGI</strong>)
附言此外,查找并确保 LoadModule cgi_module 未被注释。
4) 搜索和替换
<strong>#</strong>AddHandler cgi-script .cgi
with (...删除 # )
AddHandler cgi-script .cgi
AddHandler cgi-script .rb
5) 找到该行:
DirectoryIndex index.php index.php3 index.html index.htm
并在它们的末尾添加:index.cgi index.rb
现在,重启 Apache。
6) 创建一个 sample.rb(在 /www 根目录中),其内容如下:
#!C:\Ruby200\bin\ruby\ruby.exe
puts "Content-type: text/html" #in newer version, might be puts("....")
puts ""
puts "Test Pageeeeeeeee."
附言笔记: (a) 将 C:|Ruby.. 路径正确更改为您的 RUBY 安装路径。 (b) 为避免出现问题,请勿将 RUBY 安装在任何“文件夹名称”都包含空格的路径中。 (c) 行首和print(..
之间不能有空格7) 打开http://localhost/sample.rb
就是这样!!
p.s.注意,在某些情况下,在使用 .htaccess [在 .rb 目录内] 时,您可能需要在 .htaccess 中插入这些行:
<i>Options +ExecCGI</i>
<i>AddHandler cgi-script .rb</i>
【讨论】: