我有一台运行Ubuntu 12.04的VPS。我已按照these和these instructions在其上安装了Nginx和Passenger,并且根据说明,我已添加到http
文件块{{1}以下行:
/etc/nginx/nginx.conf
以及以下块(我已用passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /usr/bin/ruby;
替换实际域名):
www.example.com
Rails应用程序位于目录server {
listen 80;
server_name www.example.com;
root /srv/rails/myapp/public;
passenger_enabled on;
}
中,该目录也是Git项目目录。目录及其所有内容归用户/srv/rails/myapp/
所有。我已将目录设置为可写入的,并且,作为用户rails
,在其中运行以下命令:
rails
在此之后,在开发模式下运行应用程序成功:当我命令git pull
gem install bundler
bundle install
rake db:migrate
RAILS_ENV=production bundle exec rake assets:precompile
并打开http://www.example.com:3000时,应用程序正常工作。
然而,完成上述所有操作并命令rails s
后,打开http://www.example.com会产生乘客错误屏幕,其中显示: < / p>
sudo service nginx restart
下面有很多调试输出,我不确定哪个有用,但这里有一段摘录:
no such file to load -- bundler/setup (LoadError)
/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:245:in `run_load_path_setup_code'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:348:in `running_bundler'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:243:in `run_load_path_setup_code'
/usr/share/passenger/helper-scripts/rack-preloader.rb:100:in `preload_app'
/usr/share/passenger/helper-scripts/rack-preloader.rb:158
应用程序使用Ruby v2.0.0p353,而Passenger似乎使用v1.8.7;我不确定这是否与此问题有关。 (应用程序使用的Ruby位于Application root
/srv/rails/myapp
Environment (value of RAILS_ENV, RACK_ENV, WSGI_ENV and PASSENGER_ENV)
production
Ruby interpreter command
/usr/bin/ruby
User and groups
uid=1001(rails) gid=1002(rails) groups=1002(rails)
Environment variables
SHELL = /bin/bash
PASSENGER_DEBUG_DIR = /tmp/passenger.spawn-debug.XXXX2fPMPM
USER = rails
PWD = /srv/rails/myapp
SHLVL = 0
HOME = /home/rails
LOGNAME = rails
SERVER_SOFTWARE = nginx/1.4.6
IN_PASSENGER = 1
PYTHONUNBUFFERED = 1
NODE_PATH = /usr/share/passenger/node
RAILS_ENV = production
RACK_ENV = production
WSGI_ENV = production
NODE_ENV = production
PASSENGER_APP_ENV = production
SERVER_PROTOCOL = HTTP/1.1
SCGI = 1
DOCUMENT_ROOT = /srv/rails/myapp/public
QUERY_STRING =
SERVER_NAME = www.example.com
REMOTE_PORT = 49316
REMOTE_ADDR = [redacted]
SERVER_PORT = 80
REQUEST_METHOD = GET
SERVER_ADDR = [redacted]
REQUEST_URI = /
...
General Ruby interpreter information
RUBY_VERSION = 1.8.7
RUBY_PLATFORM = x86_64-linux
RUBY_ENGINE = nil
RubyGems version = 1.8.15
。)
我已经搜索了乘客输出此错误的其他问题,但到目前为止我没有尝试过任何问题来解决问题。
答案 0 :(得分:1)
我真的不知道这是否会有所帮助,但请尝试在您的项目文件夹中:
which ruby # for example /home/rails/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
这将输出你的捆绑使用的ruby。把这个值换成这个:
passenger_ruby /usr/bin/ruby;
到这个
passenger_ruby /home/rails/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
端
修改强>
这个Linux命令:
echo $MY_RUBY_HOME/bin/ruby
可能是查找ruby二进制文件的最简单,最正确的方法。
答案 1 :(得分:0)
在尝试了各种各样的事情后,我放弃了从Debian软件包安装nginx。我删除了它,并删除了我的红宝石和RVM,然后在these directions之后重新安装了所有内容。本文建议如何使用passenger gem附带的passenger-install-nginx-module
命令安装nginx。它会检查所有依赖项,如果可以继续,则下载并编译nginx。默认情况下,它安装在/opt/nginx/
。
这不会立即起作用。我还必须创建一个nginx启动脚本;说明here。此外,我必须编辑/opt/nginx/conf/nginx.conf
文件以添加对我的应用程序的引用,并且还必须注释掉location /
块。完成所有这些并命令sudo service nginx restart
后,该网站即将启动。