LoginSignup
2
3

More than 5 years have passed since last update.

smalruby-editorをEC2で起動

Posted at

スモウルビー(smalruby)について

smalruby-editorは、Scratchのように命令ブロックを組み合わせて、プログラムを作成するためのビジュアルプログラミングエディタです。命令ブロックからRubyのプログラム、また、Rubyのプログラムから命令ブロックに変換できることが特徴の一つです。
(http://smalruby.jp/blog/2017/01/14/smalruby-editor-0-4-1-has-been-released.html)

smalruby-editorはのsmalrubyのGUI環境ですね。
今回はこれをAmazonLinuxへインストールします。

smalruby-editor

下手にバージョンを変えると関連ライブラリがconflictしてエラーが出まくりハマりにハマったので、
Gemfileに指定されているRubyやRailsのバージョンで起動するのが宜しいかと思います。

指定されているバージョンは以下です。

  • Ruby 2.3.3
  • Rails 4.0.3

AmazonLinux

インストールした環境は以下。

  • AmazonLinux t2.micro

サーバーのセットアップ

インストールしたものは以下。これらのインストール方法は省略しますね。

  • Nginx 1.10.2
  • MySQL 5.5
  • Git 2.7.4
  • rbenv
  • ruby2.3.3

AmazonLinuxへSDLをインストール

インストールコマンドをシェルスクリプトにまとめてくれた方がいたので、そのまま拝借し実行しました。

gboudreau/install-ffmpeg-amazon-linux.sh

smalruby-editorのインストール

基本的にREADMEに記載されている通りに実行していけばOK。

export RAILS_ENV=production

cd /var/www/html
git clone https://github.com/smalruby/smalruby-editor.git
cd smalruby-editor
bundle
cp config/database.yml.mysql2 config/database.yml

DBの設定など。

config/database.yml

production:
  adapter: mysql2
  encoding: utf8
  database: smalruby-editor_production
  pool: 5
  username: root
  password: password
  host: localhost
bin/rake db:create
bin/rake db:migrate

起動

unicorn + Nginxの構成で起動するため、config/unicorn.rbに設定を追記しました。

config/unicorn.rb

@path = "/var/www/html/smalruby-editor/"
listen "#{@path}tmp/smalruby-editor.sock"
pid "#{@path}tmp/pids/unicorn.pid"
stderr_path "#{@path}log/unicorn.stderr.log"
stdout_path "#{@path}log/unicorn.stdout.log"

Nginx側の設定

/etc/nginx/conf.d/unicorn.conf

upstream unicorn {
  # nginxとunicornの連携
  server unix:/var/www/html/smalruby-editor/tmp/smalruby-editor.sock;
}

server {
  listen       80 default_server;
  access_log /var/log/nginx/smalruby-editor_access.log;
  error_log /var/log/nginx/smalruby-editor_error.log;

  root /var/www/html/smalruby-editor/public;

  try_files $uri/index.html $uri @unicorn;

  client_max_body_size 20M;

  location @unicorn {
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header Host $http_host;
     proxy_pass http://unicorn;
  }
}

最後にunicornとnginxを起動。

bin/bundle exec unicorn -c config/unicorn.rb -E production -D
/etc/init.d/nginx start
2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3