我与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
所以,我想知道发生了什么事:这个包是否强制自己被passenger使用,也就是说,重写PassengerRuby?我是否配置错误或错过了一些设置或环境变量?我问的问题对吗?感谢所有的帮助!!现在已经一个月了,服务器管理员一直告诉我,我没有正确配置路径,等等,但是我的胃告诉我应该给你写信!(谢谢JP !)
您已经将PassengerRuby
放在.conf
文件的ENV部分中。它不是一个ENV变量,而是一个mod_passenger.c
的设置。
这个应该会更好:
<IfModule mod_passenger.c>
...
PassengerRuby "/usr/local/bin/ruby"
...
</IfModule>
我认为您遇到的问题是基于乘客中的错误在您的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 install
或bundle update
。
问题是,当你在Gemfile中指定ruby版本时,我认为它会在安装gems时覆盖你在系统中的版本。