我想在Ubuntu上尝试构建SHIRASAGI的故事

由于想要创建SHIRASAGI的Vagrantfile,所以先试着进行了设置的挑战。顺便一提,由于无法访问网页,所以未完成状态。

系统要求

    • ubuntu Server 14.04LTS

 

    • Unicorn

 

    • MongoDB 3.0

 

    • Ruby 2.2.2

 

    Ruby on Rails 4.2.3

命令记录

创建Vagrant环境并安装Ruby on Rails

% vagrant init precise64 http://files.vagrantup.com/precise64.box 
% vagrant up
% vagrant ssh 
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic x86_64)

 * Documentation:  https://help.ubuntu.com/
New release '14.04.3 LTS' available.
Run 'do-release-upgrade' to upgrade to it.

Welcome to your Vagrant-built virtual machine.
Last login: Fri Sep 14 06:23:18 2012 from 10.0.2.2

#Ubuntuのバージョンをアップデート
$ do-release-upgrade
% vagrant ssh        
Welcome to Ubuntu 14.04.3 LTS (GNU/Linux 3.13.0-65-generic x86_64)

 * Documentation:  https://help.ubuntu.com/
Welcome to your Vagrant-built virtual machine.
Last login: Sun Oct 11 01:40:33 2015 from 10.0.2.2

#Update
$ apt-get update

#Rubyアンイスコ
$ sudo aptitude purge ruby

#install rbenv
$ sudo apt-get install rbenv

#install git
$ sudo apt-get install git

#install ruby-build
$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

#insall Ruby2.2.2
$ rbenv install 2.2.2
Downloading ruby-2.2.2.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/    5ffc0f317e429e6b29d4a98ac521c3ce65481bfd22a8cf845fa02a7b113d9b44
Installing ruby-2.2.2...

BUILD FAILED (Ubuntu 14.04 using ruby-build 20150928-2-g717a54c)

Inspect or clean up the working tree at /tmp/ruby-build.20151011034515.2028
Results logged to /tmp/ruby-build.20151011034515.2028.log

#check error log
$ vi /tmp/ruby-build.20151011034515.2028.log
<中略>
checking if make is GNU make... ./configure: line 23197: make: command not found

#install make
$ apt-get install make

#retry
$ rbenv install 2.2.2
Installed ruby-2.2.2 to /root/.rbenv/versions/2.2.2

#use global
$ rbenv global 2.2.2
$ ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]

#Setting.gemrc
$ vi ~/.gemrc
install: --no-ri --no-rdoc
update: --no-ri --no-rdoc

#install Ruby on Rails
$ gem install rails --version="4.2.3"

#rbenvの更新
$ rbenv rehash

对于SHIRASAGI而言,需要的一切。

#installe ImageMagick
$ aptitude install imagemagick libimagemagick libmagickcore libmagickcore-dev libmagickwand-dev

#install mongoDB
$ apt-get install mongodb-10gen
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package mongodb-10gen

#Retry install mongoDB
#http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
$ apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
$ echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
$ apt-get install -y mongodb-org

#install bundler
$ gem install bundler

#install SHIRASAGI
$ git clone -b stable --depth 1 https://github.com/shirasagi/shirasagi /var/www/shirasagi

#IF install OpenData Plugin
$ git clone -b stable --depth 1 https://github.com/shirasagi/opendata /var/www/shirasagi

#START SHIRASAGI
$ cd /var/www/shirasagi
$ cp -n config/samples/*.{yml,rb} config/
$ bundle install
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

/root/.rbenv/versions/2.2.2/bin/ruby -r ./siteconf20151011-19263-xj6a5.rb extconf.rb
checking for main() in -lstdc++... no
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling unf.cc
make: g++: Command not found
make: *** [unf.o] Error 127

make failed, exit code 2

Gem files will remain installed in /root/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/unf_ext-0.0.7.1 for inspection.
Results logged to /root/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/extensions/x86_64-linux/2.2.0-static/unf_ext-0.0.7.1/gem_make.out
An error occurred while installing unf_ext (0.0.7.1), and Bundler cannot continue.
Make sure that `gem install unf_ext -v '0.0.7.1'` succeeds before bundling.

#Retry
$ apt-get install build-essential g++
$ bundle install

$ rake unicorn:start
http___localhost_3000__mypage_に接続できません.png

为什么呢…

独角兽似乎在移动。

$ ps -ef | grep unicorn
vagrant  22083     1  6 16:42 ?        00:00:10 unicorn_rails master -c /var/www/shirasagi/config/unicorn.rb -E production -D                                      
vagrant  22090 22083  0 16:42 ?        00:00:00 unicorn_rails worker[0] -c /var/www/shirasagi/config/unicorn.rb -E production -D                                   
vagrant  22093 22083  0 16:42 ?        00:00:00 unicorn_rails worker[1] -c /var/www/shirasagi/config/unicorn.rb -E production -D 

一旦有进展,将更新。

気になるところ・トラブルメモ

Ubuntuのバージョンが古い

需要使用14.04或更高版的系统。
请手动更新,但应该先确认是否有最新版本的虚拟机镜像文件可用。