<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Marco2016 (小闹)</title>
    <link>https://ruby-china.org/Marco2016</link>
    <description></description>
    <language>en-us</language>
    <item>
      <title>Ubuntu 14.04 上使用 Nginx + Passenger 部署 Ruby on Rails 错误， cannot load such file -- bundler/setup</title>
      <description>&lt;p&gt;在本地和 Heroku 上均可以运行&lt;br&gt;
但是想练习使用 Nginx, Passenger, Capistrano 进行部署时却出现错误&lt;br&gt;
&lt;img src="https://l.ruby-china.com/photo/2016/9ff2c5afb36b520059b3f25f051784a8.png" width="500px" height="300px" alt=""&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;/etc/nginx/sites-enabled/default 这里就用的 gorails 给的写法&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        server_name 域名;
        passenger_enabled on;
        rails_env    production;
        root         /home/deploy/myapp/current/public;

        # redirect server error pages to the static page /50x.html
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;/var/log/nginx/error.log&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[ 2016-10-23 03:40:38.1167 24173/7fbabb218700 age/Cor/App/Implementation.cpp:304 ]: Could not spawn process for application /home/deploy/myapp/current: An error occurred while starting up the preloader.
  Error ID: de709b70
  Error details saved to: /tmp/passenger-error-U7XDgA.html
  Message from application: cannot load such file -- bundler/setup (LoadError)
  /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
  /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:430:in `activate_gem'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:297:in `block in run_load_path_setup_code'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:435:in `running_bundler'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:296: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:156:in `&amp;lt;module:App&amp;gt;'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `&amp;lt;module:PhusionPassenger&amp;gt;'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `&amp;lt;main&amp;gt;'


[ 2016-10-23 03:40:38.1291 24173/7fbabc21a700 age/Cor/Con/CheckoutSession.cpp:285 ]: [Client 1-3] Cannot checkout session because a spawning error occurred. The identifier of the error is de709b70. Please see earlier logs for details about the error.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;参考了论坛里如下几篇类似问题的解决方法，仍然没有悟道适合的办法&lt;br&gt;
&lt;a href="https://ruby-china.org/topics/30114" rel="nofollow" target="_blank"&gt;https://ruby-china.org/topics/30114&lt;/a&gt;&lt;br&gt;
&lt;a href="https://ruby-china.org/topics/22368" rel="nofollow" target="_blank"&gt;https://ruby-china.org/topics/22368&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/peatio/peatio/issues/225" rel="nofollow" target="_blank"&gt;https://github.com/peatio/peatio/issues/225&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;麻烦诸位指点下&lt;/p&gt;

&lt;p&gt;=====================================================================================&lt;br&gt;
新错误提示：&lt;br&gt;
在服务器上用 sudo service nginx restart 显示 ok 的，但是网页完全打不开了，显示 ERR_CONNECTION_REFUSED&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;04:37 passenger:restart
      01 passenger-config restart-app /home/deploy/myapp --ignore-app-not-running

passenger-config stderr: *** ERROR: Phusion Passenger doesn't seem to be running. If you are sure that it
is running, then the causes of this problem could be one of:

 1. You customized the instance registry directory using Apache's
    PassengerInstanceRegistryDir option, Nginx's
    passenger_instance_registry_dir option, or Phusion Passenger Standalone's
    --instance-registry-dir command line argument. If so, please set the
    environment variable PASSENGER_INSTANCE_REGISTRY_DIR to that directory
    and run this command again.
 2. The instance directory has been removed by an operating system background
    service. Please set a different instance registry directory using Apache's
    PassengerInstanceRegistryDir option, Nginx's passenger_instance_registry_dir
    option, or Phusion Passenger Standalone's --instance-registry-dir command
    line argument.


** DEPLOY FAILED
** Refer to log/capistrano.log for details. Here are the last 20 lines:


 DEBUG [469b6021]       PassengerInstanceRegistryDir option, Nginx's

 DEBUG [469b6021]   

 DEBUG [469b6021]       passenger_instance_registry_dir option, or Phusion Passenger Standalone's

 DEBUG [469b6021]   

 DEBUG [469b6021]       --instance-registry-dir command line argument. If so, please set the

 DEBUG [469b6021]   

 DEBUG [469b6021]       environment variable PASSENGER_INSTANCE_REGISTRY_DIR to that directory

 DEBUG [469b6021]   

 DEBUG [469b6021]       and run this command again.

 DEBUG [469b6021]   

 DEBUG [469b6021]    2. The instance directory has been removed by an operating system background

 DEBUG [469b6021]   

 DEBUG [469b6021]       service. Please set a different instance registry directory using Apache's

 DEBUG [469b6021]   

 DEBUG [469b6021]       PassengerInstanceRegistryDir option, Nginx's passenger_instance_registry_dir

 DEBUG [469b6021]   

 DEBUG [469b6021]       option, or Phusion Passenger Standalone's --instance-registry-dir command

 DEBUG [469b6021]   

 DEBUG [469b6021]       line argument.

 DEBUG [469b6021]
&lt;/code&gt;&lt;/pre&gt;</description>
      <author>Marco2016</author>
      <pubDate>Sun, 23 Oct 2016 12:50:40 +0800</pubDate>
      <link>https://ruby-china.org/topics/31414</link>
      <guid>https://ruby-china.org/topics/31414</guid>
    </item>
  </channel>
</rss>
