LoginSignup
1
0

More than 5 years have passed since last update.

Locomotive V3 (LocomotiveCMS) Engineインストール編

Posted at

LocomotiveCMSの新しいバージョンLocomotive V3がリリースされたのでさっそくインストールしてみました。ローカルでサイトを開発するツールであるWagonについては、Wagonインストール編を参照して下さい。EngineのインストールもInstall Engineそのままですが、ところどころ補足します。

0. 前提条件

  • MongoDB 2.6.x or 3.x
  • Ruby 2.1 (or upper)
  • Ruby on Rails 4.2.5 (or higher)

Mac OS X El Capitan/MongoDB 3.2.0/Ruby 2.2.1p85/Rails 4.2.5にて確認。

1. インストール

Railsアプリを作成します。

$ rails new locomotiveapp --skip-bundle --skip-active-record
$ cd locomotiveapp

Gemfileに追記します。

Gemfile
gem 'locomotivecms', '~> 3.0.0'

bundleを更新し、EngineのConfigurationファイルをインストールします。途中、アセット用にAmazon S3を使用するか訊かれます。

$ bundle install
$ bundle exec rails generate locomotive:install
      create  config/initializers/locomotive.rb
      create  config/initializers/devise.rb
      create  config/initializers/dragonfly.rb
      create  config/mongoid.yml
Do you want to store your assets on Amazon S3? n
      create  config/initializers/carrierwave.rb
       route  
  # Locomotive Back-office
  mount Locomotive::Engine => '/locomotive', as: 'locomotive' # you can change the value of the path, by default set to "/locomotive"

  # Locomotive API
  mount Locomotive::API.to_app => '/locomotive(/:site_handle)/api'

  # Render site
  mount Locomotive::Steam::Server.to_app => '/', anchor: false
      remove  public/index.html
      insert  Gemfile
===============================================================================

The Locomotive Engine has been correctly installed in your Rails application.

  1. Edit the main config files:

    - config/initializers/carrierwave.rb
    - config/initializers/devise.rb
    - config/initializers/dragonfly.rb
    - config/initializers/locomotive.rb
    - config/devise.yml
    - config/mongoid.yml
    - config/routes.rb

  2. Launch the server

    > bundle exec rails server

  3. Open your browser

    > open localhost:3000

  4. Enjoy !

===============================================================================

ローカルサーバーを起動すると、http://localhost:3000/locomotive でSign inページが表示されます。

$ bundle exec rails server

2. 新規アカウントとサイトの作成

"Do not have an account?"リンクからサイト管理用のアカウントを追加すると、そのままログイン状態になります。

"Add a new site"ボタンを押下して、新しいサイトを作成すると、サイトのDashboardページに移動します。左側にあるDevelopersをクリックすると、Wagonサイトのインストール手順が説明されています。

たった今サーバー側に作成したサイトから、"wagon clone"コマンドにて、ローカルで編集するためのwagonサイトを作成する方法も説明されていますが、すでにWagonインストール編で個別に作成しておいたサイトがありますので、そちらを使用することにします。以下から出来合いのサンプルサイトをダウンロードすることもできます。

$ curl -O https://wagonapp.s3.amazonaws.com/myportfolio.zip
$ unzip myportfolio.zip
$ cd My\ portfolio/
$ bundle install

3.Wagonサイトをディプロイ(プッシュ)

いずれの方法にせよ、clone以外の方法で個別に作成したwagonサイトの場合、Developersページに説明されている通りにconfig/deploy.ymlに追記してディプロイしてみます。

config/deploy.yml
production:
  host: http://localhost:3000
  handle: random-string-987
  email: foo@bar.com
  api_key: {contidential}

定義した任意の環境名(この場合はproduction)を指定して、ディプロイします。

bundle exec wagon deploy production

Wagonインストール編でWagonサイトをサーバー側へディプロイしたように、"wagon auth"でログインしておき、未定義の環境名を指定してインタラクティブにディプロイする方法もあります。その場合、サーバー側に受け皿のサイトを事前に作成しておく必要はありません。

1
0
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
1
0