前回のエントリのあとごちょごちょやってたらとりあえず動くようになったので、書いておく。
まず、依存しているらしいパッケージを apt install
でインストール。
- libgmp3-dev
- libsqlite3-dev
専用ユーザの作りなおし。
takatoh@wplj $ sudo adduser tonzlr takatoh@wplj $ sudo gpasswd -a tonzlr sudo
作ったユーザでログインして、GitHub からクローン。
tonzlr@wplj:~$ git clone https://github.com/takatoh/Tonzlr.git tonzlr
bundle install
。
tonzlr@wplj:~$ cd tonzlr tonzlr@wplj:~/tonzlr$ bundle install --path vendor/bundle Fetching gem metadata from https://rubygems.org/.......... Fetching version metadata from https://rubygems.org/.. Fetching dependency metadata from https://rubygems.org/. Installing rake 10.4.2 Installing i18n 0.7.0 Installing json 1.8.1 with native extensions Installing minitest 5.5.0 Installing thread_safe 0.3.4 Installing builder 3.2.2 Installing erubis 2.7.0 Installing rack 1.5.2 Installing mime-types 1.25.1 Installing polyglot 0.3.5 Installing arel 5.0.1.20140414130214 Installing coffee-script-source 1.8.0 Installing execjs 2.2.2 Installing thor 0.19.1 Installing hike 1.2.3 Installing multi_json 1.10.1 Installing libv8 3.16.14.3 (x86_64-linux) Using bundler 1.14.6 Installing tilt 1.4.1 Installing ref 1.0.5 Installing sass 3.2.19 Installing spring 1.2.0 Installing sqlite3 1.3.10 with native extensions Installing will_paginate 3.0.7 Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /home/tonzlr/tonzlr/vendor/bundle/ruby/2.3.0/gems/json-1.8.1/ext/json/ext/generator /usr/bin/ruby2.3 -r ./siteconf20170304-6634-1swo6wh.rb extconf.rb creating Makefile current directory: /home/tonzlr/tonzlr/vendor/bundle/ruby/2.3.0/gems/json-1.8.1/ext/json/ext/generator make "DESTDIR=" clean current directory: /home/tonzlr/tonzlr/vendor/bundle/ruby/2.3.0/gems/json-1.8.1/ext/json/ext/generator make "DESTDIR=" compiling generator.c In file included from generator.c:1:0: ../fbuffer/fbuffer.h: In function ‘fbuffer_to_s’: ../fbuffer/fbuffer.h:175:47: error: macro "rb_str_new" requires 2 arguments, but only 1 given VALUE result = rb_str_new(FBUFFER_PAIR(fb)); ^ ../fbuffer/fbuffer.h:175:20: warning: initialization makes integer from pointer without a cast [-Wint-conversion] VALUE result = rb_str_new(FBUFFER_PAIR(fb)); ^ Makefile:239: ターゲット 'generator.o' のレシピで失敗しました make: *** [generator.o] エラー 1 make failed, exit code 2 Gem files will remain installed in /home/tonzlr/tonzlr/vendor/bundle/ruby/2.3.0/gems/json-1.8.1 for inspection. Results logged to /home/tonzlr/tonzlr/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/json-1.8.1/gem_make.out An error occurred while installing json (1.8.1), and Bundler cannot continue. Make sure that `gem install json -v '1.8.1'` succeeds before bundling.
やっぱりエラーになったけど、めげずに bundle update
。
tonzlr@wplj:~/tonzlr$ bundle update Fetching gem metadata from https://rubygems.org/.......... Fetching version metadata from https://rubygems.org/.. Fetching dependency metadata from https://rubygems.org/. Resolving dependencies... Installing rake 12.0.0 (was 10.4.2) Installing i18n 0.8.1 (was 0.7.0) Installing json 1.8.6 (was 1.8.1) with native extensions Installing minitest 5.10.1 (was 5.5.0) Installing thread_safe 0.3.6 (was 0.3.4) Installing builder 3.2.3 (was 3.2.2) Using erubis 2.7.0 Installing rack 1.5.5 (was 1.5.2) Using mime-types 1.25.1 Using polyglot 0.3.5 Using arel 5.0.1.20140414130214 Using bundler 1.14.6 Installing coffee-script-source 1.12.2 (was 1.8.0) Installing execjs 2.7.0 (was 2.2.2) Installing thor 0.19.4 (was 0.19.1) Using hike 1.2.3 Installing multi_json 1.12.1 (was 1.10.1) Installing libv8 3.16.14.17 (x86_64-linux) (was 3.16.14.3) Using tilt 1.4.1 Installing rdoc 4.3.0 (was 4.2.0) Installing ref 2.0.0 (was 1.0.5) Using sass 3.2.19 Installing spring 1.7.2 (was 1.2.0) Installing sqlite3 1.3.13 (was 1.3.10) with native extensions Installing turbolinks-source 5.0.0 Installing will_paginate 3.1.5 (was 3.0.7) Installing tzinfo 1.2.2 Installing rack-test 0.6.3 (was 0.6.2) Installing treetop 1.4.15 Installing coffee-script 2.4.1 (was 2.3.0) Installing uglifier 3.1.3 (was 2.6.0) Installing sprockets 2.12.4 (was 2.12.3) Installing sdoc 0.4.2 (was 0.4.1) Installing therubyracer 0.12.3 (was 0.12.1) with native extensions Installing turbolinks 5.0.1 (was 2.5.3) Installing activesupport 4.1.4 Installing mail 2.5.4 Installing actionview 4.1.4 Installing activemodel 4.1.4 Installing jbuilder 2.6.3 (was 2.2.6) Installing actionpack 4.1.4 Installing activerecord 4.1.4 Installing actionmailer 4.1.4 Installing railties 4.1.4 Installing sprockets-rails 2.3.3 (was 2.2.2) Installing coffee-rails 4.0.1 Installing jquery-rails 3.1.4 (was 3.1.2) Installing rails 4.1.4 Installing sass-rails 4.0.5 Bundle updated!
今度は成功。
設定ファイルの編集。
tonzlr@wplj:~/tonzlr$ cd config tonzlr@wplj:~/tonzlr/config$ cp site_config.yml.example site_config.yml tonzlr@wplj:~/tonzlr/config$ vi site_config.yml
--- development: storage_dir: ./storage-devel test: storage_dir: ./storage-test production: storage_dir: /media/aysheaia/wallpapers
データベースのマイグレーション。
tonzlr@wplj:~/tonzlr$ rake db:migrate RAILS_ENV=production == 20141229035713 CreateWallpapers: migrating ================================= -- create_table(:wallpapers) -> 0.0021s == 20141229035713 CreateWallpapers: migrated (0.0023s) ======================== == 20141229040752 CreateImages: migrating ===================================== -- create_table(:images) -> 0.0009s == 20141229040752 CreateImages: migrated (0.0010s) ============================ == 20141230093231 AddImagesCountToWallpapers: migrating ======================= -- add_column(:wallpapers, :images_count, :integer, {:default=>0}) -> 0.0038s == 20141230093231 AddImagesCountToWallpapers: migrated (0.0039s) ============== == 20141230233607 CreateTags: migrating ======================================= -- create_table(:tags) -> 0.0010s == 20141230233607 CreateTags: migrated (0.0011s) ============================== == 20141230234524 CreateTaggings: migrating =================================== -- create_table(:taggings) -> 0.0010s -- add_index(:taggings, :tag_id) -> 0.0007s -- add_index(:taggings, [:taggable_id, :taggable_type]) -> 0.0012s == 20141230234524 CreateTaggings: migrated (0.0031s) ========================== == 20141231051856 CreatePools: migrating ====================================== -- create_table(:pools) -> 0.0011s == 20141231051856 CreatePools: migrated (0.0012s) ============================= == 20141231052318 CreatePoolings: migrating =================================== -- create_table(:poolings) -> 0.0009s == 20141231052318 CreatePoolings: migrated (0.0010s) ==========================
apostrophe からデータベースを持ってきて上書き。
tonzlr@wplj:~/tonzlr$ cd db tonzlr@wplj:~/tonzlr/db$ scp tonzlr@apostrophe:tonzlr/db/production.sqlite3 . tonzlr@apostrophe's password: production.sqlite3 100% 6721KB 6.6MB/s 00:00 tonzlr@wplj:~/tonzlr/db$ cd ..
assets のプリコンパイル。
tonzlr@wplj:~/tonzlr$ rake assets:precompile I, [2017-03-04T14:51:43.129624 #7460] INFO -- : Writing /home/tonzlr/tonzlr/public/assets/application-542d4bf5c7f8bc802982fa7761156fb8.js I, [2017-03-04T14:51:43.184646 #7460] INFO -- : Writing /home/tonzlr/tonzlr/public/assets/application-9084123bb8f8533cdd8e6f85fc1b536c.css
Rails 自身で配信するように、config/environments/production.rb を編集。
# Disable Rails's static asset server (Apache or nginx will already do this). config.serve_static_assets = true
そして起動。SECRET_KEY_BASE 環境変数を設定するのを忘れないように。
tonzlr@wplj:~/tonzlr$ export SECRET_KEY_BASE=`rake secret` tonzlr@wplj:~/tonzlr$ bundle exec rails s -e production => Booting WEBrick => Rails 4.1.4 application starting in production on http://0.0.0.0:3000 => Run `rails server -h` for more startup options => Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option) => Ctrl-C to shutdown server [2017-03-04 14:55:12] INFO WEBrick 1.3.1 [2017-03-04 14:55:12] INFO ruby 2.3.1 (2016-04-26) [x86_64-linux-gnu] [2017-03-04 14:55:12] INFO WEBrick::HTTPServer#start: pid=7479 port=3000
これで、ブラウザでアクセスすると、動いているのが確認できた。