3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Windows8.1 に Vagrant + Centos6.6 + Ruby on Rails

Last updated at Posted at 2015-06-03

##1.仮想マシンの構成
###1.boxを追加

vagrant box add centos66 https://github.com/tommy-muehle/vagrant-box-centos-6.6/releases/download/1.0.0/centos-6.6-x86_64.box

###2.仮想マシンを作成

Vagrantfileの作成

vagrant init centos66

Vagrantfileの編集

config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "forwarded_port", guest: 3000, host: 4000
config.vm.network "private_network", ip: "192.168.33.10", auto_config: false

仮想マシンの起動

vagrant up

起動後はsshで接続可能
server : 127.0.0.1
user : vagrant
password : vagrant
※windowsなのでsshで接続するツールを用意する

###3.仮想マシンのスナップショットを作成
vagrant-vbox-snapshotをインストール

vagrant plugin install vagrant-vbox-snapshot

snapshotを作成する

vagrant snapshot take init

###4.Gitのインストール 古いGitを削除して ソースからインストール
# yum remove git
# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-ExtUtils-MakeMaker
# cd /usr/local/
# wget https://www.kernel.org/pub/software/scm/git/git-2.4.0.tar.gz 
# tar -zxvf git-2.4.0.tar.gz
# cd git-2.4.0
# ./configure --prefix=/usr/local
# make prefix=/usr/local all
# make prefix=/usr/local install
# git --version

###5.Postgresqlの設定
Postgresqlのインストール

# yum remove postgresql postgresql-devel postgresql-libs postgresql-server
# rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-1.noarch.rpm
# yum install -y postgresql94-server postgresql-devel
# service postgresql-9.4 initdb
# service postgresql-9.4 start
# chkconfig postgresql-9.4 on
# su - postgres -c "
    psql -c \"UPDATE pg_database SET datistemplate=false WHERE datname='template1'\"
    psql -c \"DROP DATABASE template1\"
    psql -c \"CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UTF8'\"
    psql -c \"UPDATE pg_database SET datistemplate=true WHERE datname='template1'\"
    createuser -d -S -R vagrant
    "

###6.Rubyのインストール
まずはRubyのアンインストール

$ sudo yum -y remove ruby

rbenvインストール(全てのユーザ対象)

# git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv
# echo 'export RBENV_ROOT="/usr/local/rbenv"' >> /etc/profile
# echo 'export PATH="${RBENV_ROOT}/bin:${PATH}"' >> /etc/profile
# echo 'eval "$(rbenv init -)"' >> /etc/profile

ruby-buildプラグインをインストール

# mkdir /usr/local/rbenv/plugins
# git clone git://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins
# cd /usr/local/rbenv/plugins
# ./install.sh

Host OSからreboot

vagrant reload

Rubyのインストール

# rbenv install -l
# rbenv install 2.2.2
# rbenv global 2.2.2

###7.Railsのインストール

# yum -y install libxml2 libxslt libxml2-devel libxslt-devel
# yum install sqlite-devel
# gem update
# gem install nokogiri -- --use-system-libraries
# gem install rails -v 4.2.1 --no-ri --no-rdoc
# ruby -v
3
4
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
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?