0

我在与 cPanel、EasyApache4 和 Phusion Passenger 共享服务器上。我的应用程序在 ruby​​ 2.1.6(在共享目录中)和 rails 4.2.6 上运行良好。我有一个 .htaccess 文件:

PassengerEnabled on 
PassengerLoadShellEnvVars On 
PassengerAppRoot /home/adminxxx/webapps/assist2prod/current/ 
PassengerRuby /usr/local/ruby20/bin/ruby

## General Apache options 
#AddHandler cgi-script .cgi 
#Options +FollowSymLinks +ExecCGI

# Redirect all requests not available on the filesystem to Rails 
RewriteEngine On 
RailsEnv production 
RackEnv production

#ErrorDocument 500 "<h2>Production Application error</h2>Rails application failed to start properly"

服务器决定升级,现在我必须使用 cPanel 应用程序管理器来设置我的应用程序。我发现了新的 .conf 文件:

<Location "/">
    <IfModule mod_env.c>
        SetEnv "PassengerRuby" "/usr/local/bin/ruby"
        SetEnv "RackEnv" "production"
        SetEnv "RailsEnv" "production"
    </IfModule>
    
    <IfModule mod_passenger.c>
        PassengerAppEnv "production"

        PassengerEnabled on
        PassengerBaseURI "/"
        PassengerAppRoot "/home/adminxxx/webapps/assist2prod/releases-2021old/20190707101851"
        PassengerAppGroupName "adminxxx - WisdomTorontoProduction"
        PassengerNodejs /opt/cpanel/ea-nodejs10/bin/node
    </IfModule>
</Location>
<Directory "/home/adminxxx/webapps/assist2prod/releases-2021old/20190707101851">
    Allow from all
    Options -MultiViews
    Options -Indexes
    Require all granted
</Directory>

这里有一些信息:

# /usr/local/bin/ruby -v
ruby 2.1.6p336 (2015-04-13 revision 50298) [x86_64-linux]

# /usr/local/ruby20/bin/ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [x86_64-linux]

现在,当我在应用程序管理器中启用应用程序时,我在 apache 日志文件中得到了这个:

App 792497 output: Error: The application encountered the following error: Your Ruby version is 2.4.10, but your Gemfile specified 2.1.6 (Bundler::RubyVersionMismatch)
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/local/share/gems/gems/bundler-2.2.27/lib/bundler/definition.rb:441:in `validate_ruby!'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/local/share/gems/gems/bundler-2.2.27/lib/bundler/definition.rb:416:in `validate_runtime!'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/local/share/gems/gems/bundler-2.2.27/lib/bundler.rb:143:in `setup'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/local/share/gems/gems/bundler-2.2.27/lib/bundler/setup.rb:20:in `block in <top (required)>'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/local/share/gems/gems/bundler-2.2.27/lib/bundler/ui/shell.rb:136:in `with_level'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/local/share/gems/gems/bundler-2.2.27/lib/bundler/ui/shell.rb:88:in `silence'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/local/share/gems/gems/bundler-2.2.27/lib/bundler/setup.rb:20:in `<top (required)>'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/share/passenger/phusion_passenger/loader_shared_helpers.rb:365:in `activate_gem'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/share/passenger/phusion_passenger/loader_shared_helpers.rb:221:in `block in run_load_path_setup_code'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/share/passenger/phusion_passenger/loader_shared_helpers.rb:529:in `running_bundler'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/share/passenger/phusion_passenger/loader_shared_helpers.rb:220:in `run_load_path_setup_code'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/share/passenger/helper-scripts/rack-preloader.rb:91:in `preload_app'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/share/passenger/helper-scripts/rack-preloader.rb:189:in `block in <module:App>'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/share/passenger/phusion_passenger/loader_shared_helpers.rb:382:in `run_block_and_record_step_progress'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/share/passenger/helper-scripts/rack-preloader.rb:188:in `<module:App>'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<main>'
[ E 2021-10-15 17:49:04.3920 983139/T8j age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /home/adminxxx/webapps/assist2prod/releases-2021old/20190707101851: The application encountered the following error: Your Ruby version is 2.4.10, but your Gemfile specified 2.1.6 (Bundler::RubyVersionMismatch)
  Error ID: cf24ad74
  Error details saved to: /var/run/ea-ruby24-passenger/passenger-error-cRgyLU.html

所以,我想知道发生了什么:这个包是否强制自己被乘客使用,即覆盖PassengerRuby?我是否配置错误或错过了某些设置或环境变量?我在问正确的问题吗?所有帮助表示赞赏!!!!一个月过去了,服务器管理员一直告诉我我没有正确配置路径等,但我的胃告诉我要写信给你!(谢谢JP!)

4

2 回答 2

1

我认为您遇到的问题是Gemfile基于乘客中的错误。该行:

App 792497 output: Error: The application encountered the following error: Your Ruby version is 2.4.10, but your Gemfile specified 2.1.6 (Bundler::RubyVersionMismatch)

尝试从文件顶部更改ruby "2.1.6"ruby "2.4.10",或者从您的文件中删除该行Gemfile并运行bundle installbundle update.

问题是当您在 Gemfile 中指定 ruby​​ 版本时,我认为它会在安装 gems 时覆盖系统中的版本。

于 2021-10-16T17:31:31.917 回答
1

您已放入文件PassengerRuby的 ENV 部分.conf。它不是 ENV 变量,而是mod_passenger.c.

这应该会更好:

<IfModule mod_passenger.c>
    ...
    PassengerRuby "/usr/local/bin/ruby"
    ...
</IfModule>
于 2021-10-16T13:54:32.470 回答