Rails rails 部署出错

flowerwrong · 2014年06月21日 · 最后由 jimq 回复于 2015年08月18日 · 5226 次阅读

地址:http://203.195.169.138/ 我是照着这个教程做的 https://github.com/ruby-china/ruby-china/wiki/Ubuntu-12.04-%E4%B8%8A%E4%BD%BF%E7%94%A8-Nginx-Passenger-%E9%83%A8%E7%BD%B2-Ruby-on-Rails error.log

App 8556 stdout:
App 8556 stderr:  --> Compiling passenger_native_support.so for the current Ruby interpreter...
App 8556 stderr:
App 8556 stderr:      (set PASSENGER_COMPILE_NATIVE_SUPPORT_BINARY=0 to disable)
App 8556 stderr:
App 8556 stderr:  --> Downloading precompiled passenger_native_support.so for the current Ruby interpreter...
App 8556 stderr:
App 8556 stderr:      (set PASSENGER_DOWNLOAD_NATIVE_SUPPORT_BINARY=0 to disable)
App 8556 stderr:
App 8556 stderr:      Could not download https://oss-binaries.phusionpassenger.com/binaries/passenger/by_release/4.0.45/rubyext-ruby-2.1.1-x86_64-linux.tar.gz: The requested URL returned error: 404
App 8556 stderr:      Trying next mirror...
App 8556 stderr:      Could not download https://s3.amazonaws.com/phusion-passenger/binaries/passenger/by_release/4.0.45/rubyext-ruby-2.1.1-x86_64-linux.tar.gz: connect() timed out!
App 8556 stderr:  --> Continuing without passenger_native_support.so.
App 8556 stdout:
[ 2014-06-21 04:00:12.2888 8338/7f87b3115700 Pool2/Implementation.cpp:883 ]: Could not spawn process for group /var/www/xmis#default: An error occured while starting up the preloader.
     in 'void Passenger::ApplicationPool2::SmartSpawner::handleErrorResponse(Passenger::ApplicationPool2::SmartSpawner::StartupDetails&)' (SmartSpawner.h:451)
     in 'std::string Passenger::ApplicationPool2::SmartSpawner::negotiatePreloaderStartup(Passenger::ApplicationPool2::SmartSpawner::StartupDetails&)' (SmartSpawner.h:562)
     in 'void Passenger::ApplicationPool2::SmartSpawner::startPreloader()' (SmartSpawner.h:202)
     in 'virtual Passenger::ApplicationPool2::ProcessPtr Passenger::ApplicationPool2::SmartSpawner::spawn(const Passenger::ApplicationPool2::Options&)' (SmartSpawner.h:746)
     in 'void Passenger::ApplicationPool2::Group::spawnThreadRealMain(const SpawnerPtr&, const Passenger::ApplicationPool2::Options&, unsigned int)' (Implementation.cpp:804)

[ 2014-06-21 04:00:12.2891 8338/7f87b0df0700 agents/HelperAgent/RequestHandler.h:2262 ]: [Client 20] Cannot checkout session.
Error page:
<p>It looks like Bundler could not find a gem. Maybe you didn't install all the gems that this application needs. To install your gems, please run:</p>

  <pre class="commands">bundle install</pre>

<p>If that didn't work, then the problem is probably caused by your application being run under a different environment than it's supposed to. Please check the following:</p>

<ol>
  <li>Is this app supposed to be run as the <code>nobody</code> user?</li>
  <li>Is this app being run on the correct Ruby interpreter? Below you will
      see which Ruby interpreter Phusion Passenger attempted to use.</li>
  <li>Please check whether the correct RVM gemset is being used.</li>
  <li>Sometimes, RVM gemsets may be broken.
      <a href="https://github.com/phusion/passenger/wiki/Resetting-RVM-gemsets">Try resetting them.</a></li>
</ol>
<p>-------- The exception is as follows: -------</p>
git://github.com/rweng/jquery-datatables-rails.git (at master) is not yet checked out. Run `bundle install` first. (Bundler::GitError)
<pre>  /home/ubuntu/.rvm/gems/ruby-2.1.1/gems/bundler-1.6.3/lib/bundler/source/git.rb:187:in `rescue in load_spec_files&#39;
  /home/ubuntu/.rvm/gems/ruby-2.1.1/gems/bundler-1.6.3/lib/bundler/source/git.rb:184:in `load_spec_files&#39;
  /home/ubuntu/.rvm/gems/ruby-2.1.1/gems/bundler-1.6.3/lib/bundler/source/path.rb:92:in `local_specs&#39;
  /home/ubuntu/.rvm/gems/ruby-2.1.1/gems/bundler-1.6.3/lib/bundler/source/git.rb:154:in `specs&#39;
  /home/ubuntu/.rvm/gems/ruby-2.1.1/gems/bundler-1.6.3/lib/bundler/lazy_specification.rb:53:in `__materialize__&#39;
  /home/ubuntu/.rvm/gems/ruby-2.1.1/gems/bundler-1.6.3/lib/bundler/spec_set.rb:88:in `block in materialize&#39;
  /home/ubuntu/.rvm/gems/ruby-2.1.1/gems/bundler-1.6.3/lib/bundler/spec_set.rb:85:in `map!&#39;
  /home/ubuntu/.rvm/gems/ruby-2.1.1/gems/bundler-1.6.3/lib/bundler/spec_set.rb:85:in `materialize&#39;
  /home/ubuntu/.rvm/gems/ruby-2.1.1/gems/bundler-1.6.3/lib/bundler/definition.rb:133:in `specs&#39;
  /home/ubuntu/.rvm/gems/ruby-2.1.1/gems/bundler-1.6.3/lib/bundler/definition.rb:178:in `specs_for&#39;
  /home/ubuntu/.rvm/gems/ruby-2.1.1/gems/bundler-1.6.3/lib/bundler/definition.rb:167:in `requested_specs&#39;
  /home/ubuntu/.rvm/gems/ruby-2.1.1/gems/bundler-1.6.3/lib/bundler/environment.rb:18:in `requested_specs&#39;
  /home/ubuntu/.rvm/gems/ruby-2.1.1/gems/bundler-1.6.3/lib/bundler/runtime.rb:13:in `setup&#39;
  /home/ubuntu/.rvm/gems/ruby-2.1.1/gems/bundler-1.6.3/lib/bundler.rb:120:in `setup&#39;
  /home/ubuntu/.rvm/gems/ruby-2.1.1/gems/bundler-1.6.3/lib/bundler/setup.rb:17:in `&lt;top (required)&gt;&#39;
  /home/ubuntu/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `require&#39;
  /home/ubuntu/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require&#39;
  /home/ubuntu/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require&#39;
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:258:in `block in run_load_path_setup_code&#39;
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:361:in `running_bundler&#39;
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:256:in `run_load_path_setup_code&#39;
  /usr/share/passenger/helper-scripts/rack-preloader.rb:100:in `preload_app&#39;
  /usr/share/passenger/helper-scripts/rack-preloader.rb:158:in `&lt;module:App&gt;&#39;
  /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `&lt;module:PhusionPassenger&gt;&#39;
  /usr/share/passenger/helper-scripts/rack-preloader.rb:28:in `&lt;main&gt;&#39;</pre>

下载地址 404 了。。。。。。。。。

App 8556 stderr:      Could not download https://oss-binaries.phusionpassenger.com/binaries/passenger/by_release/4.0.45/rubyext-ruby-2.1.1-x86_64-linux.tar.gz: The requested URL returned error: 404
App 8556 stderr:      Trying next mirror...
App 8556 stderr:      Could not download https://s3.amazonaws.com/phusion-passenger/binaries/passenger/by_release/4.0.45/rubyext-ruby-2.1.1-x86_64-linux.tar.gz: connect() timed out!

细看

#2 楼 @huacnlee 昨晚看到这段了,也有人在 stanticover...上提问,但是没解决。那地址 404 http://stackoverflow.com/questions/6238399/phusion-passenger-compiles-extension-for-wrong-ruby-when-using-rvm

#4 楼 @nouse passenger 我就是看这个文档安装的。

<p>It looks like Bundler could not find a gem. Maybe you didn't install all the gems that this application needs. To install your gems, please run:</p>

  <pre class="commands">bundle install</pre>

还有,很多人提问的时候说“按照这个教程来做”,麻烦指出做到哪一步出现错误,不然完全没有头绪。

#6 楼 @Rei 执行过了的,而且反复试过很多遍。还是不行。

\curl -sSL https://get.rvm.io | bash
rvm use --install --default 2.1.1

安装 Passenger

https://www.phusionpassenger.com/documentation/Users%20guide%20Nginx.html#install_on_debian_ubuntu
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7
sudo apt-get install apt-transport-https ca-certificates
sudo touch /etc/apt/sources.list.d/passenger.list
"""
# Ubuntu 12.04
deb https://oss-binaries.phusionpassenger.com/apt/passenger precise main
"""
sudo chown root: /etc/apt/sources.list.d/passenger.list
sudo chmod 600 /etc/apt/sources.list.d/passenger.list
sudo apt-get update
sudo apt-get install nginx-extras passenger
sudo service nginx restart

现在修改 nginx 配置,编辑 /etc/nginx/nginx.conf,找到这两行注释

passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /home/ubuntu/.rvm/wrappers/default/ruby;

git clone

git clone https://github.com/FlowerWrong/xmis.git
cd xmis
bundle install
RAILS_ENV=production rake db:create db:migrate

配置 nginx

sudo rm /etc/nginx/sites-enabled/default
sudo vim /etc/nginx/sites-enabled/example.com.conf
server {
    listen 80 default;
    server_name example.com; # 这里填写你真实域名
    root /var/www/xmis/public;
    passenger_enabled on;
}
sudo service nginx restart

#7 楼 @flowerwrong

git://github.com/rweng/jquery-datatables-rails.git (at master) is not yet checked out. Run `bundle install` first. (Bundler::GitError)

至少有一个 gem 没安装成功。

#8 楼 @Rei 我执行bundle install都是成功的,特地看了 jquery-datatables-rails.git 也没问题。 我觉得主要问题在

Continuing without passenger_native_support.so.

奥,目前这个地址确实 404,再查一下先。

我觉得它能 Continuing,说明不是一个必须的东西。

你登录用户用的 ruby 和 passenger 环境用的 ruby 版本是否相同?

#12 楼 @Rei

passenger_ruby /home/ubuntu/.rvm/wrappers/default/ruby;
ruby -v
2.1.1

还有就是 rails s 在开发环境和生产环境都没问题。 passenger_ruby /home/ubuntu/.rvm/wrappers/default/ruby;

sudo passenger-status也没问题

#14 楼 @Rei


rvm rubies

=* ruby-2.1.2 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

#15 楼 @flowerwrong 检查下怎么这里是 2.1.2?

#16 楼 @Rei 我重新整个重做了一遍,问题解决了,但是我还是不知道哪里的问题,开始用的是 2.1.1,重做的时候用了最新的 2.1.2,不知道是不是这个问题。

http://203.195.169.138/login

谢谢大家,nginx+passenger 的配置问题算是解决了,发现 rails 生产环境还是有好多问题没解决。继续学习。

https://github.com/ruby-china/ruby-china/wiki/Ubuntu-12.04-%E4%B8%8A%E4%BD%BF%E7%94%A8-Nginx-Passenger-%E9%83%A8%E7%BD%B2-Ruby-on-Rails

推荐下。

@flowerwrong 请问你这个问题最后是怎么解决的?我今天在 ubuntu 12.04 上部署,做到“sudo apt-get install -y nginx-extras passenger”这一步时也报如下错误,貌似找不到目标地址:

Err https://oss-binaries.phusionpassenger.com/apt/passenger/ precise/main passenger amd64 1:5.0.15-1~precise1
  Operation too slow. Less than 10 bytes/sec transferred the last 3 seconds
Err https://oss-binaries.phusionpassenger.com/apt/passenger/ precise/main nginx-extras amd64 1:1.8.0-8.5.0.15~precise1
  Operation too slow. Less than 10 bytes/sec transferred the last 3 seconds
Failed to fetch https://oss-binaries.phusionpassenger.com/apt/passenger/pool/precise/main/p/passenger/passenger_5.0.15-1~precise1_amd64.deb  Operation too slow. Less than 10 bytes/sec transferred the last 3 seconds
需要 登录 后方可回复, 如果你还没有账号请 注册新账号