Posted at

SHIRASAGIをUbuntuでビルドしてみたかった話

More than 3 years have passed since last update.

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」でアクセスできるらしいが・・・

http___localhost_3000__mypage_に接続できません.png

なぜだ・・・


unicorn自体は動いているみたい

$ 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以上が必要。

手作業アップデートしておくが、最新版のboxがないか確認しておくべき。