如何与 WampServer 一起安装 Ruby on Rails?
是否可以将 Ruby on Rails 与 WampServer 一起安装(并保留 WampServer 的 Apache/MySQL 安装)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
是否可以将 Ruby on Rails 与 WampServer 一起安装(并保留 WampServer 的 Apache/MySQL 安装)?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(4)
我将 Ruby on Rails 与 WampServer 一起安装。操作方法如下:
将以下文本中的
C:\wamp\
替换为您自己的 WampServer 的安装存储库。安装 Ruby:
C:\wamp\ruby\
。将 Ruby 的 bin 存储库添加到 PATH 环境变量中:
;C:\wamp\ruby\bin
附加到 Path 变量。安装 DevKit:
下载 DevKit:
c:\wamp\ruby\DevKit
。cd /dc:\wamp\ruby\DevKit
。ruby dk.rb 初始化
。- c:\wamp\ruby
添加到config.yml
末尾。ruby dk.rb install
安装 Rails 和 Mongrel 服务器:
打开命令行并输入:
从
C:\wamp\www\rails\ 打开命令行并输入:
创建您的第一个 Rails 应用程序p>安装 Mongrel 服务器和 Windows Mongrel 服务来创建您的第一个 Rails 应用程序,确保以管理员身份运行命令行:
为 Rails 应用程序安装 Windows 服务:
启动 Mongrel 服务:
您现在可以通过
http://localhost:3001/
访问您的 Rails 应用程序。与 Apache 集成
在 httpd.conf 中启用 mod_proxy
打开 httpd.conf (c:\wamp\bin\apache\Apache2.xx\conf\httpd.conf) 并取消注释以下行:
转发您的流量到你的 Mongrel 服务器。将以下文本添加到您的 httpd.conf(或 extra/httpd-vhosts.conf,如果它包含在您的 httpd.conf 中):
将 hello.com 添加到您的主机文件。在记事本中打开
c:\windows\system32\drivers\etc\hosts
并添加以下行:<预><代码>127.0.0.1 www.hello.com hello.com
您现在可以转到 http://www.hello.com 它应该加载您的 Rails 应用程序。
参考文献:
I installed Ruby on Rails alongside WampServer. Here is how to do it:
Replace
C:\wamp\
in the following text by your own WampServer's install repository.Installing Ruby:
C:\wamp\ruby\
.Add Ruby's bin repository in your PATH environment variable:
;C:\wamp\ruby\bin
to the Path variable.Installing DevKit:
Download DevKit:
c:\wamp\ruby\DevKit
.cd /d c:\wamp\ruby\DevKit
.ruby dk.rb init
.- c:\wamp\ruby
to the end ofconfig.yml
.ruby dk.rb install
Installing Rails and the Mongrel server:
Open the command line and type:
Create your first Rails application by opening the command line from
C:\wamp\www\rails\
and typing:Install the Mongrel server and Windows Mongrel service, making sure to run the command line as administrator:
Install a Windows service for your Rails application:
Start your Mongrel service:
You can now access your Rails application at
http://localhost:3001/
.Integrating with Apache
Enable mod_proxy in httpd.conf
Open httpd.conf (c:\wamp\bin\apache\Apache2.x.x\conf\httpd.conf) and uncomment the following line:
Forward your traffic to your Mongrel server. Add the following text to your httpd.conf (or extra/httpd-vhosts.conf if it's included in your httpd.conf):
Add hello.com to your hosts file. Open
c:\windows\system32\drivers\etc\hosts
in Notepad and add the following line:You can now go to http://www.hello.com and it should load your Rails application.
References:
是的,有 InstantRails
Yes, There is InstantRails
这是假设您正在尝试设置开发环境,因为对生产服务器使用 Windows 和/或 WAMP 没有多大意义。
您可以使用 Ruby 安装程序 在 Windows 上相当轻松地安装 Ruby。还有一键安装程序,其中包含许多库(尽管您可以安装稍后您可以自己使用 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 才能使其工作。
This is assuming you're trying to set up a development environment, because it doesn't make much sense to use Windows and/or WAMP for a production server.
You can instally Ruby rather easily on Windows using the Ruby installer. There's also the one-click installer which includes a number of libraries (though you can install these yourself with rubygems later).
You are correct in that you install Rails (and dependencies) as a gem.
Now, as for Apache... I'm going to suggest that you keep your WAMP installation and simply don't use it for Ruby/Rails. Ruby has a built-in web server called WEBrick, and there's another light-weight server called Mongrel (available as a gem). These can be run simultaneously with Apache, with Apache serving PHP content and Mongrel/WEBrick serving Rails. They'll run on different ports (Apache on 80, Mongrel/WEBrick on 3000 by default), so there shouldn't be any conflicts.
There are several advantages with this approach:
MySQL is separate from Apache, so your Rails app will be able to access MySQL databases regardless of which server is serving its content. Naturally, you'll have to run at least the MySQL version of WAMP in order for it to work.
要在本地主机(wampserver 等)上安装+运行 Ruby On Rails 应用程序:
使用独立的 Ruby Server 安装: a) http://railsinstaller.org/en b) http://www. helicontech.com/zoo/install.html c) https://bitnami.com/stack/ruby< /a>
或
1) 安装WAMP(或其他)
2) 安装 Ruby
3) 打开...wamp\bin\apache\apacheXXXX\conf\httpd.conf,然后搜索&代替
选项索引 FollowSymLinks
与
选项索引 FollowSymLinks ExecCGI
(或选项索引 FollowSymLinks 包括 ExecCGI
)ps还有,查找&确保 LoadModule cgi_module 没有被注释。
4) 搜索&代替
#AddHandler cgi-script .cgi
与(...删除 # )
AddHandler cgi-script .cgi
AddHandler cgi-script .rb
5) 找到以下行:
DirectoryIndexindex.phpindex.php3index.htmlindex.htm
并在它们的末尾添加:
index.cgi index.rb
现在,重新启动 Apache。
6) 创建一个 sample.rb (在 /www 根目录中),内容如下:
ps 注意:
(a) 将 C:|Ruby.. 路径正确更改为您的 RUBY 安装路径。 (b) 为避免出现问题,请勿将 RUBY 安装在任何“文件夹名称”包含空格的路径中。 (c) 行首和 print(..) 之间不应有空格
7) 打开
http://localhost/sample.rb
仅此而已!!
ps注意,在某些情况下,在使用 .htaccess [在 .rb 目录内]时,您可能需要在 .htaccess 中插入这些行:
选项+ExecCGI
AddHandler cgi-script .rb
To install+run Ruby On Rails application on localhost (wampserver or etc):
USE standalone Ruby Server installations: a) http://railsinstaller.org/en b) http://www.helicontech.com/zoo/install.html c) https://bitnami.com/stack/ruby
OR
1) Install WAMP (or etc)
2) Install Ruby
3) open ...wamp\bin\apache\apacheXXXX\conf\httpd.conf, then search & replace
Options Indexes FollowSymLinks
with
Options Indexes FollowSymLinks ExecCGI
(orOptions Indexes FollowSymLinks Includes ExecCGI
)p.s. also, Find & ensure that LoadModule cgi_module is NOT commented.
4) search & replace
#AddHandler cgi-script .cgi
with (...removing # )
AddHandler cgi-script .cgi
AddHandler cgi-script .rb
5) Find the line:
DirectoryIndex index.php index.php3 index.html index.htm
and add in the end of them:
index.cgi index.rb
Now, Restart Apache.
6) create a sample.rb (in /www root), with such content:
p.s. NOTE:
(a) Change C:|Ruby.. path to your RUBY installation path correctly. (b) To avoid problems, dont install RUBY in a path, wherein any "folder name" contains a space. (c) There should not be a space between the start of line and print(..
7) open
http://localhost/sample.rb
THAT's all!!
p.s.note, in come cases, while using .htaccess [inside .rb directory], you might need to insert these lines in .htaccess:
Options +ExecCGI
AddHandler cgi-script .rb