使用 RVM 时 Phusion-passenger 编译错误 ruby​​ 扩展

发布于 2024-11-14 06:44:33 字数 3428 浏览 2 评论 0原文

我已经使用 Ruby 1.9.2 在系统范围内设置了 RVM,据我所知,它运行良好。

但是当我尝试通过它编译 Passenger apache2 模块时,

passenger-install-apache2-module

它会为系统的 1.8.7 编译它(ext/ruby 文件夹包含 ruby-1.8.7-x86_64-linux)并且当我启动 apache 时,Passenger 抱怨:

*** Phusion Passenger: no passenger_native_support.so found for the current Ruby interpreter. Compiling one...
# mkdir -p /usr/local/rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/ext/ruby/ruby-1.9.2-x86_64-linux

但问题是 Apache 在只读文件系统上运行,因此 Passenger 无法在运行时编译模块。我需要做什么才能让它为 Ruby 1.9.2 预先编译?

我什至删除了原始的 /usr/bin/ruby18 二进制文件,然后它以错误结束:

Compiling and installing Apache 2 module...
cd /usr/local/rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7
/usr/local/rvm/wrappers/ruby-1.9.2-p180/rake apache2:clean apache2 RELEASE=yes
# /usr/local/rvm/wrappers/ruby-1.9.2-p180/rake apache2:clean apache2 RELEASE=yes
/usr/bin/env: ruby18: No such file or directory

PS。我在这里读过一些类似的问题,但似乎没有一个直接适用。文件 /usr/local/rvm/gems/ruby-1.9.2-p180/bin/passenger-install-apache2-module 具有 ...1.9 的正确 she-bang 行。 2-p180/bin/ruby

编辑:添加了更多信息

Apache Passenger conf 是:

LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7
PassengerRuby /usr/local/rvm/rubies/ruby-1.9.2-p180/bin/ruby
PassengerLogLevel 3
PassengerDebugLogFile /tmp/passenger.log

为了以防万一它有帮助,我发布了 rvm info 输出。

ruby-1.9.2-p180:

  system:
    uname:       "Linux aevastaja 2.6.31-gentoo-r6 #2 SMP Wed Jan 6 19:40:30 EET 2010 x86_64 GNU/Linux"
    bash:        "/bin/bash => GNU bash, version 4.1.9(2)-release (x86_64-pc-linux-gnu)"
    zsh:         " => not installed"

  rvm:
    version:      "rvm 1.6.18 by Wayne E. Seguin ([email protected]) [https://rvm.beginrescueend.com/]"

  ruby:
    interpreter:  "ruby"
    version:      "1.9.2p180"
    date:         "2011-02-18"
    platform:     "x86_64-linux"
    patchlevel:   "2011-02-18 revision 30909"
    full_version: "ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]"

  homes:
    gem:          "/usr/local/rvm/gems/ruby-1.9.2-p180"
    ruby:         "/usr/local/rvm/rubies/ruby-1.9.2-p180"

  binaries:
    ruby:         "/usr/local/rvm/rubies/ruby-1.9.2-p180/bin/ruby"
    irb:          "/usr/local/rvm/rubies/ruby-1.9.2-p180/bin/irb"
    gem:          "/usr/local/rvm/rubies/ruby-1.9.2-p180/bin/gem"
    rake:         "/usr/local/rvm/gems/ruby-1.9.2-p180/bin/rake"

  environment:
    PATH:         "/usr/local/rvm/gems/ruby-1.9.2-p180/bin:/usr/local/rvm/gems/ruby-1.9.2-p180@global/bin:/usr/local/rvm/rubies/ruby-1.9.2-p180/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.4.5"
    GEM_HOME:     "/usr/local/rvm/gems/ruby-1.9.2-p180"
    GEM_PATH:     "/usr/local/rvm/gems/ruby-1.9.2-p180:/usr/local/rvm/gems/ruby-1.9.2-p180@global"
    MY_RUBY_HOME: "/usr/local/rvm/rubies/ruby-1.9.2-p180"
    IRBRC:        "/usr/local/rvm/rubies/ruby-1.9.2-p180/.irbrc"
    RUBYOPT:      ""
    gemset:       ""

I have set up RVM system-wide with Ruby 1.9.2 and as far as I can tell, it works fine.

But when I try to compile Passenger apache2 module via

passenger-install-apache2-module

It compiles it for system's 1.8.7 (the ext/ruby folder contains ruby-1.8.7-x86_64-linux) and when I start apache, the Passenger complains:

*** Phusion Passenger: no passenger_native_support.so found for the current Ruby interpreter. Compiling one...
# mkdir -p /usr/local/rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/ext/ruby/ruby-1.9.2-x86_64-linux

But the problem is that Apache runs on read-only filesystem, thus Passenger fails to compile the module at runtime. What do I need to do to get it to compile it beforehand for Ruby 1.9.2?

I've even removed original /usr/bin/ruby18 binary and then it ends in error:

Compiling and installing Apache 2 module...
cd /usr/local/rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7
/usr/local/rvm/wrappers/ruby-1.9.2-p180/rake apache2:clean apache2 RELEASE=yes
# /usr/local/rvm/wrappers/ruby-1.9.2-p180/rake apache2:clean apache2 RELEASE=yes
/usr/bin/env: ruby18: No such file or directory

PS. I have read few similar questions here, but none seem to apply directly. The file /usr/local/rvm/gems/ruby-1.9.2-p180/bin/passenger-install-apache2-module has correct she-bang row for ...1.9.2-p180/bin/ruby.

EDIT: Added more info

Apache Passenger conf is:

LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7
PassengerRuby /usr/local/rvm/rubies/ruby-1.9.2-p180/bin/ruby
PassengerLogLevel 3
PassengerDebugLogFile /tmp/passenger.log

And just in case it is helpful I post rvm info output.

ruby-1.9.2-p180:

  system:
    uname:       "Linux aevastaja 2.6.31-gentoo-r6 #2 SMP Wed Jan 6 19:40:30 EET 2010 x86_64 GNU/Linux"
    bash:        "/bin/bash => GNU bash, version 4.1.9(2)-release (x86_64-pc-linux-gnu)"
    zsh:         " => not installed"

  rvm:
    version:      "rvm 1.6.18 by Wayne E. Seguin ([email protected]) [https://rvm.beginrescueend.com/]"

  ruby:
    interpreter:  "ruby"
    version:      "1.9.2p180"
    date:         "2011-02-18"
    platform:     "x86_64-linux"
    patchlevel:   "2011-02-18 revision 30909"
    full_version: "ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]"

  homes:
    gem:          "/usr/local/rvm/gems/ruby-1.9.2-p180"
    ruby:         "/usr/local/rvm/rubies/ruby-1.9.2-p180"

  binaries:
    ruby:         "/usr/local/rvm/rubies/ruby-1.9.2-p180/bin/ruby"
    irb:          "/usr/local/rvm/rubies/ruby-1.9.2-p180/bin/irb"
    gem:          "/usr/local/rvm/rubies/ruby-1.9.2-p180/bin/gem"
    rake:         "/usr/local/rvm/gems/ruby-1.9.2-p180/bin/rake"

  environment:
    PATH:         "/usr/local/rvm/gems/ruby-1.9.2-p180/bin:/usr/local/rvm/gems/ruby-1.9.2-p180@global/bin:/usr/local/rvm/rubies/ruby-1.9.2-p180/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.4.5"
    GEM_HOME:     "/usr/local/rvm/gems/ruby-1.9.2-p180"
    GEM_PATH:     "/usr/local/rvm/gems/ruby-1.9.2-p180:/usr/local/rvm/gems/ruby-1.9.2-p180@global"
    MY_RUBY_HOME: "/usr/local/rvm/rubies/ruby-1.9.2-p180"
    IRBRC:        "/usr/local/rvm/rubies/ruby-1.9.2-p180/.irbrc"
    RUBYOPT:      ""
    gemset:       ""

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

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

发布评论

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

评论(7

我ぃ本無心為│何有愛 2024-11-21 06:44:34

对于其他遇到此问题的人,请注意,Passenger 可能会从配置文件(例如,/etc/httpd/conf.d/passenger.conf)获取提示,而不是从您的主 Apache 配置文件中获取提示。

For others with this issue, please note that Passenger may be taking cues from a config file (e.g., /etc/httpd/conf.d/passenger.conf) other than your primary Apache config file.

后eg是否自 2024-11-21 06:44:34

我通常将 Passenger 安装在 global gemset 下,然后为其创建一个包装器。以下指南显示了每个步骤。

I typically install Passenger under the global gemset and then create a wrapper for it. The following guide shows each step.

白鸥掠海 2024-11-21 06:44:34

我知道,聚会晚了好几年,但这就是为我解决的问题:

在为 Ruby 1.8.7 和 2.0.0 运行 Passenger-install-apache2-module 后,我最终得到了 Passenger_native_support.so:

/usr/local/rvm/gems/ruby-1.8.7-p371/gems/passenger-4.0.5/libout/ruby/ruby-1.8.7-x86_64-linux/passenger_native_support.so
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/passenger-4.0.5/libout/ruby/ruby-2.0.0-x86_64-linux/passenger_native_support.so

我设置了 PassengerDefaultRuby对于特定的虚拟主机,PassengerRuby 设置为 2.0.0 包装器,而 PassengerRuby 设置为 1.8.7 包装器。 1.8.7 应用程序无法启动,因为 Passenger 不知道在哪里查找 1.8.7 版本的 Passenger_native_support.so,并且没有写入权限来编译新版本。

有两个选项可以解决此问题:1.)使用 PASSENGER_NATIVE_SUPPORT_OUTPUT_DIR 设置一个具有写入权限的新目录,或 2.)将 1.8.7 输出目录符号链接到 2.0.0 输出目录,例如

$ ls -l /usr/local/rvm/gems/ruby-2.0.0-p195/gems/passenger-4.0.5/libout/ruby
  ruby-1.8.7-x86_64-linux -> /usr/local/rvm/gems/ruby-1.8.7-p371/gems/passenger-4.0.5/libout/ruby/ruby-1.8.7-x86_64-linux
  ruby-2.0.0-x86_64-linux

Years late to the party, I know, but here's what fixed it for me:

After running passenger-install-apache2-module for both Ruby 1.8.7 and 2.0.0, I ended up with passenger_native_support.so in:

/usr/local/rvm/gems/ruby-1.8.7-p371/gems/passenger-4.0.5/libout/ruby/ruby-1.8.7-x86_64-linux/passenger_native_support.so
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/passenger-4.0.5/libout/ruby/ruby-2.0.0-x86_64-linux/passenger_native_support.so

I had PassengerDefaultRuby set to a 2.0.0 wrapper, and for a particular virtual host, PassengerRuby set to a 1.8.7 wrapper. The 1.8.7 app would not start because Passenger didn't know where to look for the 1.8.7 version of passenger_native_support.so and had no write access to compile a new one.

Two options to fix this: 1.) Set a new directory with PASSENGER_NATIVE_SUPPORT_OUTPUT_DIR that it did have access to write to, or 2.) symlink the 1.8.7 output dir to the 2.0.0 output dir, e.g.

$ ls -l /usr/local/rvm/gems/ruby-2.0.0-p195/gems/passenger-4.0.5/libout/ruby
  ruby-1.8.7-x86_64-linux -> /usr/local/rvm/gems/ruby-1.8.7-p371/gems/passenger-4.0.5/libout/ruby/ruby-1.8.7-x86_64-linux
  ruby-2.0.0-x86_64-linux
王权女流氓 2024-11-21 06:44:34

您在运行乘客安装之前是否切换了 Ruby?

rvm use 1.9.2

您可以使用以下命令检查当前的 Ruby(和 gemset 等):

rvm info

Have you switched your Ruby before running the passenger install?

rvm use 1.9.2

You can check your current Ruby (and gemset, etc) with:

rvm info
情话难免假 2024-11-21 06:44:34

事实证明,显然在安装较新的 Rake gem 时,我的环境错误,尽管 gem 最终出现在 1.9.2 下的 RVM 中,但它实际上引用了系统 1.8.7 二进制文件,并且 Passenger 安装脚本运行了此 rake,后者又构建了针对错误 ruby​​ 的模块。

帮助卸载并重新安装 Rake gem。

Turns out that apparently while installing newer Rake gem, I had had the environment wrong and though the gem ended up in RVM under 1.9.2, it actually referenced system 1.8.7 binary and that Passenger install script ran this rake, which in turn built the module against wrong ruby.

Helped to uninstall and reinstall Rake gem.

围归者 2024-11-21 06:44:34

需要设置“GEM_HOME”变量。

将其添加到您的乘客配置文件中(例如:/etc/apache2/mods-enabled/passenger.conf):

SetEnv GEM_HOME /usr/local/rvm/gems/ruby-2.3.1

当然,更改此“ruby-2.3.1”与您的实际版本。


一个更广泛的例子:

<IfModule mod_passenger.c>
  SetEnv GEM_HOME /usr/local/rvm/gems/ruby-2.3.1
  PassengerRoot /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini
  PassengerDefaultRuby /usr/bin/passenger_free_ruby
</IfModule>

Will need to set the "GEM_HOME" variable.

Add this to your passenger config file (eg: /etc/apache2/mods-enabled/passenger.conf):

SetEnv GEM_HOME /usr/local/rvm/gems/ruby-2.3.1

Of course, change this "ruby-2.3.1" with your actual version.


A more extensive example:

<IfModule mod_passenger.c>
  SetEnv GEM_HOME /usr/local/rvm/gems/ruby-2.3.1
  PassengerRoot /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini
  PassengerDefaultRuby /usr/bin/passenger_free_ruby
</IfModule>
少女七分熟 2024-11-21 06:44:33

如果您对不同的项目使用不同的 ruby​​ 版本,您可能只需要 native-support,并且可以在切换到正确的 ruby​​ 版本后运行 passenger-config build-native-support

使用passenger-config build-native-support --help 查看该命令将为哪个 ruby​​ 版本构建本机支持。

If you use different ruby-version for different ites, you may only need the native-support and can just run passenger-config build-native-support after switching to the right ruby-version.

Use passenger-config build-native-support --help to see for which ruby-version the command will build the native support.

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