3
3

More than 5 years have passed since last update.

Vagrant + Chefでnode.js開発環境構築

Last updated at Posted at 2015-05-23

VagrantとChefでnode.jsの開発環境を構築してみます。
Berksfileにrecipe[npm]を追加するとエラーになってしまうようです。

環境:MacOSX 10.9.5

Chefをインストール

Development Kitでインストールする。
まず、https://downloads.getchef.com/chef-dk からpkgをダウンロードして、インストールする。

chef-dkに入っているのrubyへのパスを通す

echo 'eval "$(chef shell-init bash)"' >> ~/.bash_profile
source ~/.bash_profile

knife-soloをインストール

$ sudo chef gem install knife-solo

knifeの初期設定をする

$ knife configure

設定は全てデフォルトでOK

BerkshelfでVagrantとCookBookを用意する。

$ berks cookbook {{ディレクトリ名}}
$ cd {{ディレクトリ名}}
$ bundle install

Berksfileを編集する

source "https://supermarket.chef.io"

metadata
cookbook 'nginx'
cookbook 'mongodb'
cookbook 'nodejs'
cookbook 'forever'
cookbook 'git'

Vagrantプラグインをインストール

$ vagrant plugin install vagrant-berkshelf
$ vagrant plugin install vagrant-omnibus

Vagrantfileでboxを指定する

config.vm.box = '{{box名}}'

Vagrantfileにrecipeを追加する

    chef.run_list = [
      'recipe[ubuntu::default]',
      'recipe[nginx]',
      'recipe[nodejs]',
      'recipe[mongodb]',
      'recipe[forever]',
      'recipe[git]'
    ]

Vagrantを起動

$ vagrant up --provision

参考記事

3
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
3
3