開発環境のセットアップ

仮想OSのインストール

http://dotinstall.com/lessons/basic_local_development_v2/24803 を参考に。

VirtualBox, Vigrant

VirtualBox と Vigrant をwindows上にインストール。

box を持ってきて加える:

centos6.4:

1
2
% vagrant box add centos64box http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20131103.box
% vagrant init centos64box

centos6.5:

1
2
% vagrant box add centos65box https://github.com/2creatives/vagrant-centos/releases/download/v6.5.3/centos65-x86_64-20140116.box
% vagrant init centos65box

vi Vagrantfile で private_network 部分のコメントアウトを外す

1
2
3
# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network "private_network", ip: "192.168.33.10"

そして up, ssh

1
2
% vagrant up (時間かかる)
% vagrant ssh

ホスト側から % ssh vagrant@193.168.33.10 を確かめる

開発環境

* 最新にアップデート

1
2
3
4
5
% sudo yum update -y (時間かかる)
...
% sudo echo "options single-request-reopen" >> /etc/resolv.conf
% sudo service iptables stop
% sudo chkconfig iptables off

ssh

1
2
3
% ssh-keygen -t rsa
% eval `ssh-agent`
% ssh-add ~/.ssh/id_rsa

init files

1
2
3
4
git init
git remote add origin git@github.com:atarukodaka/dotfiles.git
git fetch origin
git merge origin/master

ruby のインストール

rbenv でruby のヴァージョンを切り替える

先にopenssl を入れておく。

1
% sudo yum -y install openssl-devel

https://github.com/sstephenson/rbenv にあるとおりやる。

1
2
3
4
5
6
7
8
9
10
11
% git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
% echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
% echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
open new terminal
% rbenv
% git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
% rbenv install 2.1.4
% rbenv rehash
% rbenv global 2.1.4
% rbenv versions

% sudo yum install ruby-devel もしておく。

その他開発環境のセットアップ

yum install

  • tree
  • wget
  • curl
  • ruby-devel

git

yum で入る git は 1.7.x と古い(–orhpan が使えない)ので 1.8 を入れる。
ただしインストールに時間がかかる。

wget https://git-core.googlecode.com/files/git-1.8.5.3.tar.gz

1
2
3
4
5
6
$ sudo yum install -y zlib-devel perl-devel gettext gcc curl-devel
$ wget https://git-core.googlecode.com/files/git-1.8.5.3.tar.gz
$ tar xfvz git-1.8.5.3.tar.gz
$ cd git-1.8.5.3; ./configure; make
$ sudo make install
$ git --version

gems

gem install bundle

heroku

https://toolbelt.heroku.com/ より “standalone”でインストール。
‘readline’ がないとか言われた場合は、
gem install rb-readline
する。

timezone の設定

1
sudo cp -p /usr/share/zoneinfo/Japan /etc/localtime

共有フォルダ

vagrant の sync 機能を使って local と remote の src/ を共有する:

1
2
3
4
% vi Vagrant
...
config.vm.synced_folder "~/src", "/home/vagrant/src"
...