本文文风可能引起不适
由于各种原因,把@whtsky 同学的Gather用 Ruby 给重写了一份,在没有写完的情况下,我还是将它部署在了服务器上。
看到 @hooopo 大牛和众大牛在不断地黑 rvm 顺便推 ruby-install + chruby 搞得我小鹿乱撞于是就禁不住诱惑试了一把。
###安装 ruby-install 和 chruby 按照官方文档的说法,在
wget -O chruby-0.3.8.tar.gz https://github.com/postmodern/chruby/archive/v0.3.8.tar.gz
tar -xzvf chruby-0.3.8.tar.gz
cd chruby-0.3.8/
sudo sh ./script/setup.sh
之后就可以美滋滋地享用啦,不过这个脚本自动安装的 rubie 版本有点低,没事,咱自己ruby-install ruby 2.1.2
装一个。
安装完成了之后,在终端轻轻键入chruby ruby-2.1.2
就可以开始美滋滋地地享用啦!
###安装 passenger 和 nginx
根据多年装逼的经验,在终端轻轻敲入以下代码:
gem install passenger passenger-install-nginx-module
于是在漫长的等待后 nginx 就编译好了,在简单配置好 nginx 的配置文件后,美滋滋地打开浏览器窗口……
Ooops……500 啦~于是赶快屁颠屁颠地滚去终端看错误日志
[ 2014-07-29 15:18:14.8779 5779/7f8edff12700 Pool2/Implementation.cpp:284 ]: Could not spawn process for application /home/ubuntu/g: An error occured while starting up the preloader.
Error ID: f52f97ba
Error details saved to: /tmp/passenger-error-Hjwpav.html
Message from application: <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>ubuntu</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>
</ol>
<p>-------- The exception is as follows: -------</p>
Could not find coffee-script-source-1.7.1 in any of the sources (Bundler::GemNotFound)
<pre> /opt/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.5/lib/bundler/spec_set.rb:92:in `block in materialize'
/opt/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.5/lib/bundler/spec_set.rb:85:in `map!'
/opt/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.5/lib/bundler/spec_set.rb:85:in `materialize'
/opt/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.5/lib/bundler/definition.rb:133:in `specs'
/opt/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.5/lib/bundler/definition.rb:178:in `specs_for'
/opt/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.5/lib/bundler/definition.rb:167:in `requested_specs'
/opt/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.5/lib/bundler/environment.rb:18:in `requested_specs'
/opt/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.5/lib/bundler/runtime.rb:13:in `setup'
/opt/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.5/lib/bundler.rb:120:in `setup'
/opt/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.5/lib/bundler/setup.rb:17:in `<top (required)>'
/opt/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `require'
/opt/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
/opt/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
/opt/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.48/lib/phusion_passenger/loader_shared_helpers.rb:263:in `block in run_load_path_setup_code'
/opt/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.48/lib/phusion_passenger/loader_shared_helpers.rb:366:in `running_bundler'
/opt/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.48/lib/phusion_passenger/loader_shared_helpers.rb:261:in `run_load_path_setup_code'
/opt/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.48/helper-scripts/rack-preloader.rb:100:in `preload_app'
/opt/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.48/helper-scripts/rack-preloader.rb:158:in `<module:App>'
/opt/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.48/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
/opt/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.48/helper-scripts/rack-preloader.rb:28:in `<main>'</pre>
[ 2014-07-29 15:18:14.8854 5779/7f8eddda5700 agents/HelperAgent/RequestHandler.h:2305 ]: [Client 21] Cannot checkout session because a spawning error occurred. The identifier of the error is . Please see earlier logs for details about the error.
App 10708 stdout:
App 10708 stderr: /usr/bin/env:
App 10708 stderr: ruby
App 10708 stderr: : No such file or directory
App 10708 stderr:
App 10708 stdout:
咦,我明明装好了coffee-script-source
这个 gem 啊,一转眼看下面,ruby 环境没有配置好,于是在一番 Google 之后在 https://ruby-china.org/topics/20385 ,找到了答案:
只需要在 ~/.bash_profile 里加一句:
chruby ruby-2.1.2
好,刷新页面,页面是出来了,可出来的却是 sprockets 的错误信息,按照提示貌似是 yui 的问题,好,在 Google 大法后,装好 jre,部署完成。
###总结以及所谓的坑
体验了一番之后,发现这一套方案,不仅小,而且方便,的确让 rvm 庞大的体积以及各种环境问题无地自容,但是,在使用 passenger 部署时,一定不要忘记在 ~/.bash_profile 里加一句chruby ruby-2.1.2
最后打个小广告:
这个论坛在:https://g.nnya.nl/ 跑着,代码在 https://github.com/NyankoRevo/Gather 。(作为一个高三狗我会抽时间写完的
(Gather)[https://g.nnya.nl/ ] 是一个小圈子,虽然我们不排外:)