Apache2 的 Rails Passenger 问题

发布于 2024-11-15 03:31:49 字数 1119 浏览 2 评论 0原文

我正在尝试使用 apache2 和 mod_rails (Phusion Passenger) 在 ubuntu10.10 上设置 ruby​​ on Rails 服务器。

我已经安装了 ruby​​ 1.9.2-p0 和 Rails 3.0.8,并安装了 Passenger 以及 Passenger-install-apache2-module 和 Passenger gem (v3.0.7)。

然后它告诉我将 3 行添加到我的 Apache 配置文件中。所以我将这些行添加到 '/etc/apache2/apache2.conf':

LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.7/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/gems/1.9.1/gems/passenger-3.0.7
PassengerRuby /usr/local/bin/ruby

我编辑了我的 '/etc/apache2/httpd.conf' 并添加:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName 192.168.0.2
DocumentRoot /var/www/webop/public

<Directory /var/www/webop/public>
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>

我还发现 /usr/local/ 中的文件 mod_passenger.so lib/ruby/gems/1.9.1/gems/passenger-3.0.7/ext/apache2/ 实际上不存在,它的名称是 mod_passenger.c。但我没有从中得到任何错误。

服务器只能通过 LAN 访问。当我访问服务器时,我看到应用程序的公共文件夹中的所有文件和目录,但应用程序本身并未启动。

当我重新启动 apache 时,它​​告诉我 mod_rails 已经加载,所以我猜乘客正在运行,但我不明白为什么它不启动我的应用程序!

提前致谢!

I'm trying to setup a ruby on rails server on ubuntu10.10 with apache2 and mod_rails (Phusion Passenger).

I already installed ruby 1.9.2-p0 and rails 3.0.8 and installed Passenger with the passenger-install-apache2-module and the passenger gem (v3.0.7).

It then tells me to add 3 lines to my Apache config file. So I added these lines to '/etc/apache2/apache2.conf':

LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.7/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/gems/1.9.1/gems/passenger-3.0.7
PassengerRuby /usr/local/bin/ruby

And I edited my '/etc/apache2/httpd.conf' and added:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName 192.168.0.2
DocumentRoot /var/www/webop/public

<Directory /var/www/webop/public>
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>

I also found out that the file mod_passenger.so in /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.7/ext/apache2/ actually does not exist, its name is mod_passenger.c. But I don't get any errors from that.

The server should only be accessible through a LAN. When I access the server I see all the files and directories in the public folder of my app but the app itself does not get started.

When I restart apache it tells me that mod_rails is already loaded so I guess that passenger is running but I can't figure out why it doesn't start my app!

Thanks in advance!

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

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

发布评论

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

评论(4

撞了怀 2024-11-22 03:31:49

mod_passenger.so不存在的原因是您还没有安装Apache模块。执行:

passenger-install-apache2-module

这将在您的 gem 目录中创建 mod_passenger.so 文件,并为您提供三行内容以将其复制到 apache2.conf 文件中。

乘客模块安装在您当前的 gemset 中,因此项目之间不应该出现任何冲突。您可以通过 RVM 使用任何兼容版本的 Ruby 以及您喜欢的任何 gemset,也可能通过 RBENV。这使得从一个 Ruby 版本到下一个版本的升级变得非常简单。

The reason mod_passenger.so does not exist is because you haven't installed the Apache module. Execute:

passenger-install-apache2-module

This will create the mod_passenger.so file inside your gem directory, and give you three lines to copy into your apache2.conf file.

The passenger module is installed in your current gemset so you shouldn't get any conflicts between projects. You can use any compatible version of Ruby, and any gemset you like, via RVM, and possibly also RBENV. This makes for a nice easy upgrade path from one version of Ruby to the next.

人间☆小暴躁 2024-11-22 03:31:49

我终于明白了问题所在:我搞乱了我的红宝石安装。

在 /usr/local/ 中,我安装了 ruby​​1.9.2-p0 (这是我想使用的版本),但在 /usr/ 中,我安装了 ruby​​1.8.7。

Passenger 很困惑要使用哪个 ruby​​ 版本,所以我将 apache2/mods-enabled/passenger.load 和 .config 中的 LoadModule、PassengerRoot 和 PassengerRuby 路径更改为正确的路径,最终成功了!这两个文件都是自动创建的,这也导致了重新定义的问题:在 apache 启动时,出现警告“mod_passenger 已加载”。所以我

LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.7/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/gems/1.9.1/gems/passenger-3.0.7
PassengerRuby /usr/local/bin/ruby

从 apache 配置中删除了,警告就消失了!

也许有一天这会帮助别人!

I finally figured out what the problem was: I messed up my ruby installation.

In /usr/local/ I had ruby1.9.2-p0 installed (which was the version I wanted to use) but in /usr/ i had ruby1.8.7 installed.

Passenger was confused which ruby version to use so I changed the LoadModule, PassengerRoot and PassengerRuby paths within apache2/mods-enabled/passenger.load and .config to the correct paths and it finally worked! Both files were created automatically which also caused the problem of a redefinition: On apache startup there was a warning 'mod_passenger already loaded'. So I removed

LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.7/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/gems/1.9.1/gems/passenger-3.0.7
PassengerRuby /usr/local/bin/ruby

from the apache config and the warning disappeared!

Probably this will help someone else some day!

梦开始←不甜 2024-11-22 03:31:49

我今天遇到了一个更清洁的解决方案。这可能会对未来的用户有所帮助。命令 -

passenger-install-apache2-module

告诉我将这三行放入 apache 配置文件中。

LoadModule passenger_module /home/anwar/.rvm/gems/ruby-2.2.0/gems/passenger-4.0.59/buildout/apache2/mod_passenger.so
   <IfModule mod_passenger.c>
     PassengerRoot /home/anwar/.rvm/gems/ruby-2.2.0/gems/passenger-4.0.59
     PassengerDefaultRuby /home/anwar/.rvm/gems/ruby-2.2.0/wrappers/ruby
   </IfModule>

但是,该配置文件在哪里?答案是配置文件被分成许多部分并且它们驻留在/etc/apache2/mods-available中。

因此,您应该做三件事 -

  1. /etc/apache2/mods-available 文件夹中创建一个以 .load 结尾的文件。我使用了passenger.load

  2. 将三行粘贴到该文件中并保存文件。

  3. 现在在终端中使用 sudo a2enmod 启用该模块。就我而言,该文件是passenger.load。所以,我用了

    sudo a2enmod 乘客
    

Now,重新启动服务器并使用命令apache2ctl -M发现passenger模块已启用。

I have come across a cleaner solution today. This might help future users. The command -

passenger-install-apache2-module

tells me to put these three lines in apache configuration file.

LoadModule passenger_module /home/anwar/.rvm/gems/ruby-2.2.0/gems/passenger-4.0.59/buildout/apache2/mod_passenger.so
   <IfModule mod_passenger.c>
     PassengerRoot /home/anwar/.rvm/gems/ruby-2.2.0/gems/passenger-4.0.59
     PassengerDefaultRuby /home/anwar/.rvm/gems/ruby-2.2.0/wrappers/ruby
   </IfModule>

But, where is that configuration file? The answer is the configuration files are seperated into many pieces and they reside in /etc/apache2/mods-available.

So you should do three things -

  1. Create a file ending with .load in /etc/apache2/mods-available folder. I used passenger.load.

  2. Paste the three lines in that file and save the file.

  3. Now in terminal use sudo a2enmod <module-conf-filename> to enable the module. In my case, the file was, passenger.load. So, I used

    sudo a2enmod passenger
    

Now, restart the server and use the command apache2ctl -M to find that passenger module is enabled.

野生奥特曼 2024-11-22 03:31:49

我认为他们希望您将这三行放在 httpd.conf 文件中,而不是放在 apache2.conf 中。至少我一直都是这样做的。

I think they want you to put those three lines in your httpd.conf file, not in your apache2.conf. At least that's how I've always done it.

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