问题:Apache / Passenger不识别RVM
我有一个多用户安装的RVM,按照规范说明: http : //beginrescueend.com/rvm/install/
然后,我编辑了/etc/profile.d/rvm.sh以包含以下行,以便Ruby 1.9是用于login的所有用户的版本:
rvm use --default 1.9.2
我的系统中至less有3个用户:
以交互方式login到Ubuntu和乘客时 ,以下内容可以正确返回:
$ ruby -v ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
但是,实际提供这些请求的www-data用户从来不会执行/etc/profile.d/rvm.sh(或者profile.d中的任何内容)。 因此,以www数据用户身份login时总是会发生以下情况:
$ ruby -v ruby 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux]
由于这个原因,Bundler在我的开发沙箱上运行正确的Ruby版本,但在运行时出现了“无法在Ruby 1.8上安装Gem”types的错误:
$ cap deploy <snip> * executing "cd /var/www/app/releases/20111031001406 && bundle install --gemfile /var/www/app/releases/20111031001406/Gemfile --path /var/www/app/shared/bundle --deployment --quiet --without development test" servers: ["example.com"] [example.com] executing command </snip>
(example.com和应用程序是我的真实服务器和应用程序的占位符)
我收到的错误是“Linecache gem需要Ruby> 1.9”),这就是我知道Ruby 1.9.2没有运行的问题。
我如何让Apache识别RVM和我想要的Ruby版本? (根据多用户模式,在/ usr / local / rvm中安装RVM和我想要的Ruby
我已经遵循了我可以多次想到的每一条指令,但是我明显在这里错过了一些东西。 任何指导在这里将深深感激。
FWIW,这是我的Capistrano部署脚本:
# if you're still using the script/reapear helper you will need # # these http://github.com/rails/irs_process_scripts # # # bundler bootstrap require 'bundler/capistrano' set :nice_name, "App" set :application, "app" set :domain, "example.com" role :web, "#{domain}" # Your HTTP server, Apache/etc role :app, "#{domain}" # This may be the same as your `Web` server role :db, "#{domain}", :primary => true # This is where Rails migrations will run # # server details set :default_run_options, {:pty => true} set :ssh_options, {:forward_agent => true, :keys => "/path_to/ssh.key"} #ssh_options[:keys] = [File.join(ENV["HOME"], ".ssh", "id_rsa")] set :deploy_to, "/var/www/#{application}/" set :user, "passenger" set :use_sudo, false # repo details set :scm, :git set :scm_username, "githubuser" set :repository, "git://github.com/githubuser/app.git" set :branch, "master" set :git_enable_submodules, 1 # tasks namespace :deploy do task :start, :roles => :app do run "touch #{current_release}/tmp/restart.txt" end task :stop, :roles => :app do # Do nothing. end desc "Restart Application" task :restart, :roles => :app do run "touch #{current_release}/tmp/restart.txt" end desc "Symlink shared resources on each release - not used" task :symlink_shared, :roles => :app do #run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml" end end namespace :passenger do desc "Restart Application" task :restart do run "touch #{current_path}/tmp/restart.txt" end end after :deploy, "passenger:restart" after 'deploy:update_code', 'deploy:symlink_shared'
您可能需要设置PassengerRoot和PassengerRuby指令来指向您希望使用的ruby版本(由RVM控制的版本)。 如果你还没有这样做,我也build议每个应用程序使用一个gemset。 只要apache指令设置正确,您可以决定将乘客安装到您希望的任何gemset中。
示例(使用ree和Ubuntu):
sudo apt-get install build-essential bison openssl libreadline5 libreadline5-dev curl zlib1g zlib1g-dev libssl-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev autoconf libc6-dev ncurses-dev libmysqlclient15-dev apache2-prefork-dev apache2-mpm-prefork libapr1-dev libaprutil1-dev libcurl4-openssl-dev rvm use ree@${gemset_here} --create --default --passenger rvm ree@${gemset_here} gem install passenger --version="${PASSENGER_VERSION}" passenger-install-apache2-module --auto --apxs2-path $(which apxs2)
您可能需要为您的发行版获取适当的构build依赖项。 乘客编译后,你需要确保你configuration它(检查输出)。 如果您需要使用apache conf的片段,请运行以下命令:
passenger-install-apache2-module --snippet
我把它放在/etc/apache2/conf.d/passenger.conf (在Ubuntu系统上)。 您的configuration目录可能因发行版而异。 如果您在这一点上仍然遇到问题,可能需要修复您正在使用的RVM gemset目录的一些权限。