如何与 WampServer 一起安装 Ruby on Rails?

发布于 2024-08-17 12:33:23 字数 140 浏览 1 评论 0 原文

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

Is is possible to install Ruby on Rails alongside WampServer (and keep WampServer's Apache/MySQL installs)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

澉约 2024-08-24 12:33:23

我将 Ruby on Rails 与 WampServer 一起安装。操作方法如下:

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

安装 Ruby:

  1. 下载 Ruby。使用Windows二进制版本,而不是“一键安装程序”,因为它包含我们不需要的MySQL和Apache。
  2. 将 zip 解压到 C:\wamp\ruby\
  3. 将 Ruby 的 bin 存储库添加到 PATH 环境变量中:

    1. 右键单击“计算机/属性”。
    2. 点击“高级系统设置”。
    3. “高级”选项卡/环境变量。
    4. ;C:\wamp\ruby\bin 附加到 Path 变量。

安装 DevKit:

下载 DevKit:

  1. 将 DevKit 解压到 c:\wamp\ruby\DevKit
  2. cd /dc:\wamp\ruby\DevKit
  3. ruby dk.rb 初始化

    • - c:\wamp\ruby 添加到 config.yml 末尾。
  4. ruby dk.rb install

安装 Rails 和 Mongrel 服务器:

  1. 打开命令行并输入:

    gem 安装导轨
    
  2. C:\wamp\www\rails\ 打开命令行并输入: 创建您的第一个 Rails 应用程序p>

    rails 你好
    
  3. 安装 Mongrel 服务器和 Windows Mongrel 服务来创建您的第一个 Rails 应用程序,确保以管理员身份运行命令行:

    gem install mongrel 和 
    gem 安装 mongrel_service
    
  4. 为 Rails 应用程序安装 Windows 服务:

    mongrel_rails service::install -N ruby​​-hello -cc:\wamp\www\rails\hello -p 3001 -edevelopment
    
  5. 启动 Mongrel 服务:

    net start ruby​​-hello
    

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

与 Apache 集成

  1. 在 httpd.conf 中启用 mod_proxy

    打开 httpd.conf (c:\wamp\bin\apache\Apache2.xx\conf\httpd.conf) 并取消注释以下行:

    LoadModule proxy_module 模块/mod_proxy.so
    
  2. 转发您的流量到你的 Mongrel 服务器。将以下文本添加到您的 httpd.conf(或 extra/httpd-vhosts.conf,如果它包含在您的 httpd.conf 中):

    <虚拟主机 *:80>
    服务器名称 hello.com
    服务器别名 *.hello.com
    代理密码 / http://localhost:3001/
    ProxyPassReverse / http://localhost:3001
    
    
  3. 将 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:

  1. Download Ruby. Use the Windows binary version, not the "one click installer" because it contains MySQL and Apache which we don't need.
  2. Extract the zip to C:\wamp\ruby\.
  3. Add Ruby's bin repository in your PATH environment variable:

    1. Right click "Computer / Properties".
    2. Click "Advanced System Settings".
    3. Advanced tab / Environment Variables.
    4. Append ;C:\wamp\ruby\bin to the Path variable.

Installing DevKit:

Download DevKit:

  1. Extract DevKit to c:\wamp\ruby\DevKit.
  2. cd /d c:\wamp\ruby\DevKit.
  3. ruby dk.rb init.

    • Add - c:\wamp\ruby to the end of config.yml.
  4. ruby dk.rb install

Installing Rails and the Mongrel server:

  1. Open the command line and type:

    gem install rails
    
  2. Create your first Rails application by opening the command line from C:\wamp\www\rails\ and typing:

    rails hello
    
  3. Install the Mongrel server and Windows Mongrel service, making sure to run the command line as administrator:

    gem install mongrel and 
    gem install mongrel_service
    
  4. Install a Windows service for your Rails application:

    mongrel_rails service::install -N ruby-hello -c c:\wamp\www\rails\hello -p 3001 -e development
    
  5. Start your Mongrel service:

    net start ruby-hello
    

You can now access your Rails application at http://localhost:3001/.

Integrating with Apache

  1. Enable mod_proxy in httpd.conf

    Open httpd.conf (c:\wamp\bin\apache\Apache2.x.x\conf\httpd.conf) and uncomment the following line:

    LoadModule proxy_module modules/mod_proxy.so
    
  2. 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):

    <VirtualHost *:80>
    ServerName hello.com
    ServerAlias *.hello.com
    ProxyPass / http://localhost:3001/
    ProxyPassReverse / http://localhost:3001
    </VirtualHost>
    
  3. Add hello.com to your hosts file. Open c:\windows\system32\drivers\etc\hosts in Notepad and add the following line:

    127.0.0.1 www.hello.com hello.com
    

You can now go to http://www.hello.com and it should load your Rails application.

References:

傻比既视感 2024-08-24 12:33:23

是的,有 InstantRails

Yes, There is InstantRails

小ぇ时光︴ 2024-08-24 12:33:23

这是假设您正在尝试设置开发环境,因为对生产服务器使用 Windows 和/或 WAMP 没有多大意义。

您可以使用 Ruby 安装程序 在 Windows 上相当轻松地安装 Ruby。还有一键安装程序,其中包含许多库(尽管您可以安装稍后您可以自己使用 ruby​​gems)。

您将 Rails (和依赖项)安装为 gem 是正确的。

现在,对于 Apache...我建议您保留 WAMP 安装并且不要将其用于 Ruby/Rails。 Ruby 有一个名为 WEBrick 的内置 Web 服务器,还有另一个名为 Mongrel 的轻量级服务器(作为 gem 提供)。这些可以与 Apache 同时运行,Apache 提供 PHP 内容,Mongrel/WEBrick 提供 Rails。它们将在不同的端口上运行(默认情况下,Apache 在 80 上运行,Mongrel/WEBrick 在 3000 上运行),因此不应有任何冲突。

这种方法有几个优点:

  1. 您不必搞乱 WAMP 安装,也不必冒把事情搞砸的风险。
  2. 分别运行不同语言的应用程序可以保护它们免受彼此的影响。例如,如果您的 Rails 应用程序使服务器崩溃,那么如果您同时运行这两个应用程序,它不会使您的 PHP 内容也随之崩溃。
  3. 第三,最流行的 Rails IDE(RubyMine、Aptana 等)具有针对 Mongrel 和 WEBrick 服务器两者或其中之一的内置控件。这意味着您将能够在 IDE 中启动/停止/重新启动服务器,以及显示输出/日志。对于 Windows 中的 Rails 开发,我推荐 RubyMine。

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:

  1. You won't have to mess with your WAMP installation and risk screwing something up.
  2. Running applications from different languages separately protects them from each other. For example, if your Rails app crashes the server, it won't bring your PHP stuff down with it in case you're running both.
  3. Thirdly, most popular Rails IDEs (RubyMine, Aptana, etc) have built-in controls for both or one of the Mongrel and WEBrick servers. This means that you'll be able to start/stop/restart your server within the IDE, as well as display the output/logs. For Rails development in Windows, I recommend RubyMine.

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.

┾廆蒐ゝ 2024-08-24 12:33:23

要在本地主机(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 根目录中),内容如下:

#!C:\Ruby200\bin\ruby\ruby.exe
puts "Content-type: text/html" #in newer version, might be puts("....")
puts ""
puts "Test Pageeeeeeeee."

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 (or Options 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:

#!C:\Ruby200\bin\ruby\ruby.exe
puts "Content-type: text/html" #in newer version, might be puts("....")
puts ""
puts "Test Pageeeeeeeee."

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文