简体   繁体   中英

Phusion Passenger 4/Apache 2.4 can't find rack.rb

It appears this question has been asked before but I can't find the solution - it appears that I have all the right settings as generally advised elsewhere.

The error is:

cannot load such file -- rack (LoadError)
  /usr/share/passenger/helper-scripts/rack-preloader.rb:109:in `require'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:109:in `preload_app'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:160:in `<module:App>'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:28:in `<main>'

I installed RVM Ruby and it appears that my PassengerRuby is correctly pointing to this installed Ruby. The only odd thing is that GEM_PATH is not set, while there's a variable called _ORIG_GEM_PATH that is set.

Here's a dump of the relevant environment printed out by Passenger:

Application root /var/www/railsapps/postall/current Environment (value of RAILS_ENV, RACK_ENV, WSGI_ENV, NODE_ENV and PASSENGER_APP_ENV) production Ruby interpreter command

/var/www/.rvm/wrappers/ruby-2.1.5@rails4/ruby

User and groups

uid=33(www-data) gid=33(www-data) groups=33(www-data),27(sudo)

Environment variables

APACHE_PID_FILE = /var/run/apache2/apache2.pid
rvm_bin_path = /var/www/.rvm/bin
GEM_HOME = /var/www/railsapps/postall/shared/bundle/ruby/2.1.0
APACHE_RUN_USER = www-data
SHELL = /bin/bash
IRBRC = /var/www/.rvm/rubies/ruby-2.1.5/.irbrc
PYTHONUNBUFFERED = 1
RACK_BASE_URI = /postall
PASSENGER_DEBUG_DIR = /tmp/passenger.spawn-debug.XXXXoOOdYl
SERVER_PORT = 443
MY_RUBY_HOME = /var/www/.rvm/rubies/ruby-2.1.5
USER = www-data
DOCUMENT_ROOT = /var/www
HTTPS = on
_system_type = Linux
REQUEST_URI = /postall/
rvm_path = /var/www/.rvm
RAILS_RELATIVE_URL_ROOT = /postall
IN_PASSENGER = 1
RACK_ENV = production
REMOTE_PORT = 52828
rvm_prefix = /var/www
PATH = /var/www/railsapps/postall/shared/bundle/ruby/2.1.0/bin:/var/www/.rvm/gems/ruby-2.1.5@rails4/bin:/var/www/.rvm/gems/ruby-2.1.5@global/bin:/var/www/.rvm/rubies/ruby-2.1.5/bin:/var/www/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
APACHE_LOG_DIR = /var/log/apache2
WSGI_ENV = production
SERVER_ADMIN = webmaster@localhost
PWD = /var/www/railsapps/postall/current
LANG = C
APACHE_RUN_GROUP = www-data
NODE_PATH = /usr/share/passenger/node
_system_arch = x86_64
NODE_ENV = production
_system_version = 14.04
REMOTE_ADDR = 98.248.156.170
rvm_version = 1.26.9 (master)
SERVER_NAME = 192.241.223.49
HOME = /var/www
SHLVL = 0
RAILS_ENV = production
rvm_ruby_string = ruby-2.1.5
SERVER_SOFTWARE = Apache/2.4.7 (Ubuntu)
LOGNAME = www-data
QUERY_STRING = 
SERVER_ADDR = 192.241.223.49
GEM_PATH = 
SERVER_PROTOCOL = HTTP/1.1
PASSENGER_APP_ENV = production
rvm_delete_flag = 0
APACHE_RUN_DIR = /var/run/apache2
APACHE_LOCK_DIR = /var/lock/apache2
REQUEST_METHOD = GET
RUBY_VERSION = ruby-2.1.5
_system_name = Ubuntu
PASSENGER_BASE_URI = /postall
_ORIGINAL_GEM_PATH = /var/www/.rvm/gems/ruby-2.1.5@rails4:/var/www/.rvm/gems/ruby-2.1.5@global
BUNDLE_BIN_PATH = /var/www/.rvm/gems/ruby-2.1.5@global/gems/bundler-1.7.6/bin/bundle
BUNDLE_GEMFILE = /var/www/railsapps/postall/releases/20150109062343/Gemfile
RUBYOPT = -rbundler/setup
RUBYLIB = /var/www/.rvm/gems/ruby-2.1.5@global/gems/bundler-1.7.6/lib

Ruby configuration (RbConfig::CONFIG)

DESTDIR = 
MAJOR = 2
MINOR = 1
TEENY = 0
PATCHLEVEL = 273
INSTALL = /usr/bin/install
EXEEXT = 
prefix = /var/www/.rvm/rubies/ruby-2.1.5
ruby_install_name = ruby
RUBY_INSTALL_NAME = ruby
RUBY_SO_NAME = ruby
exec = exec
ruby_pc = ruby-2.1.pc
PACKAGE = ruby
BUILTIN_TRANSSRCS =  newline.c
USE_RUBYGEMS = YES
MANTYPE = doc
NROFF = /usr/bin/nroff
vendorarchhdrdir = /var/www/.rvm/rubies/ruby-2.1.5/include/ruby-2.1.0/vendor_ruby/x86_64-linux
sitearchhdrdir = /var/www/.rvm/rubies/ruby-2.1.5/include/ruby-2.1.0/site_ruby/x86_64-linux
rubyarchhdrdir = /var/www/.rvm/rubies/ruby-2.1.5/include/ruby-2.1.0/x86_64-linux
vendorhdrdir = /var/www/.rvm/rubies/ruby-2.1.5/include/ruby-2.1.0/vendor_ruby
sitehdrdir = /var/www/.rvm/rubies/ruby-2.1.5/include/ruby-2.1.0/site_ruby
rubyhdrdir = /var/www/.rvm/rubies/ruby-2.1.5/include/ruby-2.1.0
RUBY_SEARCH_PATH = 
UNIVERSAL_INTS = 
UNIVERSAL_ARCHNAMES = 
configure_args =  '--prefix=/usr/local/rvm/rubies/ruby-2.1.5' '--enable-load-relative' '--sysconfdir=/etc' '--disable-install-doc' '--enable-shared'
vendorarchdir = /var/www/.rvm/rubies/ruby-2.1.5/lib/ruby/vendor_ruby/2.1.0/x86_64-linux
vendorlibdir = /var/www/.rvm/rubies/ruby-2.1.5/lib/ruby/vendor_ruby/2.1.0
vendordir = /var/www/.rvm/rubies/ruby-2.1.5/lib/ruby/vendor_ruby
sitearchdir = /var/www/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/x86_64-linux
sitelibdir = /var/www/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0
sitedir = /var/www/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby
rubyarchdir = /var/www/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/x86_64-linux
rubylibdir = /var/www/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0
ruby_version = 2.1.0
sitearch = x86_64-linux
arch = x86_64-linux
sitearchincludedir = /var/www/.rvm/rubies/ruby-2.1.5/include/x86_64-linux
archincludedir = /var/www/.rvm/rubies/ruby-2.1.5/include/x86_64-linux
sitearchlibdir = /var/www/.rvm/rubies/ruby-2.1.5/lib/x86_64-linux
archlibdir = /var/www/.rvm/rubies/ruby-2.1.5/lib/x86_64-linux
libdirname = libdir
RUBY_EXEC_PREFIX = 
RUBY_LIB_VERSION = 
RUBY_LIB_VERSION_STYLE = 3  /* full */
RI_BASE_NAME = ri
ridir = /var/www/.rvm/rubies/ruby-2.1.5/share/ri
rubysitearchprefix = /var/www/.rvm/rubies/ruby-2.1.5/lib/ruby/x86_64-linux
rubyarchprefix = /var/www/.rvm/rubies/ruby-2.1.5/lib/ruby/x86_64-linux
MAKEFILES = Makefile GNUmakefile
PLATFORM_DIR = 
THREAD_MODEL = pthread
SYMBOL_PREFIX = 
EXPORT_PREFIX = 
COMMON_HEADERS = 
COMMON_MACROS = 
COMMON_LIBS = 
MAINLIBS = 
ENABLE_SHARED = yes
DLDLIBS =  -lc
SOLIBS = -lpthread -ldl -lcrypt -lm 
LIBRUBYARG_SHARED = -Wl,-rpath,'${ORIGIN}/../lib' -Wl,-R -Wl,'${ORIGIN}/../lib' -L'${ORIGIN}/../lib' -lruby
LIBRUBYARG_STATIC = -Wl,-rpath,'${ORIGIN}/../lib' -Wl,-R -Wl,'${ORIGIN}/../lib' -L'${ORIGIN}/../lib' -lruby-static
LIBRUBYARG = -Wl,-rpath,'${ORIGIN}/../lib' -Wl,-R -Wl,'${ORIGIN}/../lib' -L'${ORIGIN}/../lib' -lruby
LIBRUBY = libruby.so.2.1.0
LIBRUBY_ALIASES = libruby.so.2.1 libruby.so
LIBRUBY_SO = libruby.so.2.1.0
LIBRUBY_A = libruby-static.a
RUBYW_INSTALL_NAME = 
rubyw_install_name = 
EXTDLDFLAGS = 
EXTLDFLAGS = 
strict_warnflags = -ansi -std=iso9899:199409
warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration
debugflags = -ggdb3
optflags = -O3 -fno-fast-math
cxxflags =  -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration
cflags =  -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration
cppflags = 
NULLCMD = :
DLNOBJ = dln.o
INSTALLDOC = nodoc
CAPITARGET = nodoc
RDOCTARGET = nodoc
DTRACE_GLOMMED_OBJ = 
DTRACE_OBJ = 
DTRACE_EXT = dmyh
EXECUTABLE_EXTS = 
ARCHFILE = 
LIBRUBY_RELATIVE = yes
EXTOUT = .ext
RUNRUBY_COMMAND = $(MINIRUBY) $(srcdir)/tool/runruby.rb --extout=.ext $(RUNRUBYOPT)
PREP = miniruby
BTESTRUBY = $(MINIRUBY)
CROSS_COMPILING = no
TEST_RUNNABLE = yes
rubylibprefix = /var/www/.rvm/rubies/ruby-2.1.5/lib/ruby
setup = Setup
EXTSTATIC = 
STRIP = strip -S -x
TRY_LINK = 
LIBPATHENV = LD_LIBRARY_PATH
RPATHFLAG =  -Wl,-R%1$-s
LIBPATHFLAG =  -L%1$-s
LINK_SO = 
LIBEXT = a
DLEXT2 = 
DLEXT = so
LDSHAREDXX = g++ -shared
LDSHARED = gcc -shared
CCDLFLAGS = -fPIC
STATIC = 
ARCH_FLAG = 
DLDFLAGS = 
ALLOCA = 
codesign = 
POSTLINK = :
WERRORFLAG = -Werror
CHDIR = cd -P
RMALL = rm -fr
RMDIRS = rmdir --ignore-fail-on-non-empty -p
RMDIR = rmdir --ignore-fail-on-non-empty
CP = cp
RM = rm -f
PKG_CONFIG = pkg-config
PYTHON = 
DOXYGEN = 
DOT = 
DTRACE = 
MAKEDIRS = /bin/mkdir -p
MKDIR_P = /bin/mkdir -p
INSTALL_DATA = /usr/bin/install -m 644
INSTALL_SCRIPT = /usr/bin/install
INSTALL_PROGRAM = /usr/bin/install
SET_MAKE = 
LN_S = ln -s
NM = nm
DLLWRAP = 
WINDRES = 
OBJCOPY = :
OBJDUMP = objdump
ASFLAGS = 
AS = as
AR = ar
RANLIB = ranlib
try_header = 
CC_VERSION = gcc -v
COUTFLAG = -o 
OUTFLAG = -o 
CPPOUTFILE = -o conftest.i
GNU_LD = yes
LD = ld
GCC = yes
EGREP = /bin/grep -E
GREP = /bin/grep
CPP = gcc -E
CXXFLAGS =  -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration
CXX = g++
OBJEXT = o
CPPFLAGS =   
LDFLAGS = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
CFLAGS =  -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration  -fPIC
CC = gcc
NACL_SDK_VARIANT = 
NACL_SDK_ROOT = 
NACL_TOOLCHAIN = 
target_os = linux
target_vendor = unknown
target_cpu = x86_64
target = x86_64-unknown-linux-gnu
host_os = linux-gnu
host_vendor = unknown
host_cpu = x86_64
host = x86_64-unknown-linux-gnu
RUBY_VERSION_NAME = ruby-2.1.0
RUBYW_BASE_NAME = rubyw
RUBY_BASE_NAME = ruby
build_os = linux-gnu
build_vendor = unknown
build_cpu = x86_64
build = x86_64-unknown-linux-gnu
RUBY_RELEASE_DATE = 2014-11-13
RUBY_PROGRAM_VERSION = 2.1.5
target_alias = 
host_alias = 
build_alias = 
LIBS = -lpthread -ldl -lcrypt -lm 
ECHO_T = 
ECHO_N = -n
ECHO_C = 
DEFS = 
mandir = /var/www/.rvm/rubies/ruby-2.1.5/share/man
localedir = /var/www/.rvm/rubies/ruby-2.1.5/share/locale
libdir = /var/www/.rvm/rubies/ruby-2.1.5/lib
psdir = /var/www/.rvm/rubies/ruby-2.1.5/share/doc/ruby
pdfdir = /var/www/.rvm/rubies/ruby-2.1.5/share/doc/ruby
dvidir = /var/www/.rvm/rubies/ruby-2.1.5/share/doc/ruby
htmldir = /var/www/.rvm/rubies/ruby-2.1.5/share/doc/ruby
infodir = /var/www/.rvm/rubies/ruby-2.1.5/share/info
docdir = /var/www/.rvm/rubies/ruby-2.1.5/share/doc/ruby
oldincludedir = /usr/include
includedir = /var/www/.rvm/rubies/ruby-2.1.5/include
localstatedir = /var/www/.rvm/rubies/ruby-2.1.5/var
sharedstatedir = /var/www/.rvm/rubies/ruby-2.1.5/com
sysconfdir = /etc
datadir = /var/www/.rvm/rubies/ruby-2.1.5/share
datarootdir = /var/www/.rvm/rubies/ruby-2.1.5/share
libexecdir = /var/www/.rvm/rubies/ruby-2.1.5/libexec
sbindir = /var/www/.rvm/rubies/ruby-2.1.5/sbin
bindir = /var/www/.rvm/rubies/ruby-2.1.5/bin
exec_prefix = /var/www/.rvm/rubies/ruby-2.1.5
PACKAGE_URL = 
PACKAGE_BUGREPORT = 
PACKAGE_STRING = 
PACKAGE_VERSION = 
PACKAGE_TARNAME = 
PACKAGE_NAME = 
PATH_SEPARATOR = :
SHELL = /bin/bash
archdir = /var/www/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/x86_64-linux
topdir = /var/www/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/x86_64-linux

Okay, I figured it out, so here it is for anyone else who types in the corresponding search query ... the problem is indicated with the fact that the load is coming from the "system" passenger module, rather than the passenger module in the RVM gemset.

As many other websites will tell you, one way to address this is to change the value of PassengerRoot in your apache.conf file to point to where your installed gem is, in the corresponding Ruby you're using for your app. Something like:

PassengerRoot /home/myhome/.rvm/gems/ruby-2.5.1/gems/passenger-4.0.57

will get rid of this problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM