2013/07/06 shin1x1
第2回 JAWS-UG神戸
もう XAMPP / MAMP はいらない!
Vagrant を
Web開発環境に使う
@shin1x1
(c) 2013 Masashi Shinbara @shin1x1
Shin x blog
http://www.1x1.jp/blog/
PHP / DevOps / AWS /
Varnish / Fabric / Chef
開発環境
(c) 2013 Masashi Shinbara @shin1x1
Web開発あるある
エンジニアSさん
(c) 2013 Masashi Shinbara @shin1x1
• Macbook Air で開発
• Apache / PHP / DB
• 複数案件を一台で
エンジニアSさん
(c) 2013 Masashi Shinbara @shin1x1
1162 <VirtualHost *:80>
1163 ServerName candycane.local
1164 DocumentRoot "/Users/shin/sandbox/demo/candycane/app/webroot"
1165 </VirtualHost>
1166
1167 <VirtualHost *:80>
1168 ServerName demo.local
1169 DocumentRoot "/Users/shin/sandbox/demo/20130601_phpcon"
1170 php_value vld.active 1
1171 </VirtualHost>
1172
1173 <VirtualHost *:80>
1174 ServerName project1.local
1175 DocumentRoot "/Users/shin/project1/app/webroot"
1176 </VirtualHost>
1177
1178 <VirtualHost *:80>
1179 ServerName project2.local
1180 DocumentRoot "/Users/shin/project2/app/webroot"
1181 </VirtualHost>
エンジニアSさん
(c) 2013 Masashi Shinbara @shin1x1
1162 <VirtualHost *:80>
1163 ServerName candycane.local
1164 DocumentRoot "/Users/shin/sandbox/demo/candycane/app/webroot"
1165 </VirtualHost>
1166
1167 <VirtualHost *:80>
1168 ServerName demo.local
1169 DocumentRoot "/Users/shin/sandbox/demo/20130601_phpcon"
1170 php_value vld.active 1
1171 </VirtualHost>
1172
1173 <VirtualHost *:80>
1174 ServerName project1.local
1175 DocumentRoot "/Users/shin/project1/app/webroot"
1176 </VirtualHost>
1177
1178 <VirtualHost *:80>
1179 ServerName project2.local
1180 DocumentRoot "/Users/shin/project2/app/webroot"
1181 </VirtualHost>
溢れる
VirtualHost
とある開発チームA
(c) 2013 Masashi Shinbara @shin1x1
• Macbook / Windows で開発
• Apache / PHP / DB
• チームで開発
とある開発チームA
(c) 2013 Masashi Shinbara @shin1x1
あれ?動かない。
何か変なコード書いた?
こっちは動いてるよ。
モジュール入れないとダメだよ。
とある開発チームA
(c) 2013 Masashi Shinbara @shin1x1
あれ?動かない。
何か変なコード書いた?
こっちは動いてるよ。
モジュール入れないとダメだよ。
俺の環境では動く
WebデザイナーBさん
(c) 2013 Masashi Shinbara @shin1x1
• WordPressのデザイン
• XAMPPをインストール
•でもなんだか動かない。。。
(c) 2013 Masashi Shinbara @shin1x1
WebデザイナーBさん
(c) 2013 Masashi Shinbara @shin1x1
WebデザイナーBさん
Port 80 は
俺のモノ
そんなあなたに
(c) 2013 Masashi Shinbara @shin1x1
Vagrant
(c) 2013 Masashi Shinbara @shin1x1
• 誰でも全く同じ環境を構築できる
• 構成はコードで書く
• 環境構築はコマンド一つだけ
demo1
(c) 2013 Masashi Shinbara @shin1x1
httpd サーバ
demo1
(c) 2013 Masashi Shinbara @shin1x1
• VMイメージ取得
• VM起動
• プロビジョニング
• VM終了
demo1
(c) 2013 Masashi Shinbara @shin1x1
$ vagrant init
$ ls
Vagrantfile
(c) 2013 Masashi Shinbara @shin1x1
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "centos64_ja"
config.vm.provider :virtualbox do |v|
v.gui = true
end
config.vm.network :private_network, ip: "192.168.33.100"
config.vm.provision :shell,
:inline => "yum install -y httpd && /sbin/service httpd
start"
end
$ vim Vagrantfile
demo1
(c) 2013 Masashi Shinbara @shin1x1
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "centos64_ja"
config.vm.provider :virtualbox do |v|
v.gui = true
end
config.vm.network :private_network, ip: "192.168.33.100"
config.vm.provision :shell,
:inline => "yum install -y httpd && /sbin/service httpd
start"
end
$ vim Vagrantfile
demo1
VMイメージ
(c) 2013 Masashi Shinbara @shin1x1
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "centos64_ja"
config.vm.provider :virtualbox do |v|
v.gui = true
end
config.vm.network :private_network, ip: "192.168.33.100"
config.vm.provision :shell,
:inline => "yum install -y httpd && /sbin/service httpd
start"
end
$ vim Vagrantfile
demo1
GUI表示
(c) 2013 Masashi Shinbara @shin1x1
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "centos64_ja"
config.vm.provider :virtualbox do |v|
v.gui = true
end
config.vm.network :private_network, ip: "192.168.33.100"
config.vm.provision :shell,
:inline => "yum install -y httpd && /sbin/service httpd
start"
end
$ vim Vagrantfile
demo1
IPアドレス
(c) 2013 Masashi Shinbara @shin1x1
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "centos64_ja"
config.vm.provider :virtualbox do |v|
v.gui = true
end
config.vm.network :private_network, ip: "192.168.33.100"
config.vm.provision :shell,
:inline => "yum install -y httpd && /sbin/service httpd
start"
end
$ vim Vagrantfile
demo1
プロビジョニング
Chef / Puppet / Shell
(c) 2013 Masashi Shinbara @shin1x1
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'centos64_ja'...
demo1
(c) 2013 Masashi Shinbara @shin1x1
[default] Running provisioner: shell...
[default] Running: inline script
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.2.15-28.el6.centos will be
installed
demo1
(c) 2013 Masashi Shinbara @shin1x1
$ open http://192.168.33.100/
demo1
(c) 2013 Masashi Shinbara @shin1x1
$ vagrant ssh
Welcome to your Vagrant-built virtual machine.
[vagrant@localhost ~]$
$ vagrant destory
Are you sure you want to destroy the 'default' VM? [y/N] y
[default] Forcing shutdown of VM...
Connection to 127.0.0.1 closed by remote host.
[default] Destroying VM and associated drives...
demo1
demo2
(c) 2013 Masashi Shinbara @shin1x1
Wordpress
Varying Vagrant Vagrants
(c) 2013 Masashi Shinbara @shin1x1
• github で公開
https://github.com/10up/varying-vagrant-vagrants
• WordPress 環境を構築
• 20 のコンポーネントを
インストール!
Varying Vagrant Vagrants
(c) 2013 Masashi Shinbara @shin1x1
Ubuntu 12.04 LTS (Precise Pangolin) subversion 1.7.9
nginx 1.4.1 ngrep
mysql 5.5.31 dos2unix
php-fpm 5.4.15 WordPress 3.5.2
memcached 1.4.13 WordPress trunk
PHP memcache extension 3.0.6 WP-CLI
xdebug 2.2.1 WordPress Unit Tests
PHPUnit 3.7.21 Composer
ack-grep 2.04 phpMemcachedAdmin 1.2.2 BETA
git 1.8.3 phpMyAdmin 4.0.3
(c) 2013 Masashi Shinbara @shin1x1
$ git clone https://github.com/10up/
varying-vagrant-vagrants.git
$ cd varying-vagrant-vagrants
$ vagrant up
Varying Vagrant Vagrants
(c) 2013 Masashi Shinbara @shin1x1
$ open http://192.168.50.4/
demo2
(c) 2013 Masashi Shinbara @shin1x1
$ open http://local.wordpress.dev/
demo2
開発サーバ構築の流れ
(c) 2013 Masashi Shinbara @shin1x1
1. Vagrantfile 書く
2. プロビジョニング書く
3. vagrant up で構築
4. vagrant destory で破棄
(vagrant reload で再構築)
従来のツールに例えると
(c) 2013 Masashi Shinbara @shin1x1
Vagrantfile = Makefile
vagrant up = make
$ vim Makefile
$ make
$ vim Vagrantfile
$ vagrant up
Vagrant 良いところ
(c) 2013 Masashi Shinbara @shin1x1
• ホストとサーバでディレクトリ共有
=> 開発は IDE で、実行はサーバで
• IPアドレス、マシンリソース定義
• VCS(Git等) で差分管理
• 構築、配布、共有が楽
Sahara Plugin
(c) 2013 Masashi Shinbara @shin1x1
• Vagrant Plugin
https://github.com/jedi4ever/sahara
• DB の ROLLBACK のように
サーバの状態が戻せる
Sahara Plugin
(c) 2013 Masashi Shinbara @shin1x1
$ vagrant plugin install sahara
• インストール
Sahara Plugin
(c) 2013 Masashi Shinbara @shin1x1
$ vagrant sandbox on
• sandbox モード開始 = BEGIN;
$ vagrant sandbox rollback
• 元に戻す = ROLLBACK;
$ vagrant sandbox commit
• 変更確定 = COMMIT;
$ vagrant sandbox off
• sandbox モード終了
Sahara Plugin
(c) 2013 Masashi Shinbara @shin1x1
$ vagrant sandbox on
vagrant sandbox on
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...
100%
$ vagrant ssh
[vagrant@localhost ~]$ sudo rm -rf /bin
[vagrant@localhost ~]$ ls
-bash: ls: コマンドが見つかりません
[vagrant@localhost ~]$ exit
Sahara Plugin
(c) 2013 Masashi Shinbara @shin1x1
$ vagrant sandbox rollback
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...
100%
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...
100%
$ vagrant ssh
[vagrant@localhost ~]$ ls
おすすめ1
(c) 2013 Masashi Shinbara @shin1x1
http://docs.vagrantup.com/v2/
おすすめ2
(c) 2013 Masashi Shinbara @shin1x1
http://www.amazon.co.jp/dp/1449335837
Summary
(c) 2013 Masashi Shinbara @shin1x1
• 誰でも全く同じ環境を構築できる
• 構成はコードで書く
=> Vagrantfile
• 環境構築はコマンド一つだけ
=> vagrant up
@shin1x1
(c) 2013 Masashi Shinbara @shin1x1

More Related Content

PDF
もう XAMPP / MAMP はいらない!
Vagrant で作る PHP 開発環境
PDF
Vagrant で作る PHP 開発環境 [実践編]
PDF
VagrantからDockerに開発環境を移行した時の話
PDF
開発現場で活用するVagrant
PDF
Ansible ではじめるサーバ作業の自動化
PDF
Vagrant で PHP 開発環境を作る ハンズオン
PDF
ビルドサーバで使うDocker
PDF
Vagrant体験入門
もう XAMPP / MAMP はいらない!
Vagrant で作る PHP 開発環境
Vagrant で作る PHP 開発環境 [実践編]
VagrantからDockerに開発環境を移行した時の話
開発現場で活用するVagrant
Ansible ではじめるサーバ作業の自動化
Vagrant で PHP 開発環境を作る ハンズオン
ビルドサーバで使うDocker
Vagrant体験入門

What's hot (20)

PDF
Heroku で作る
スケーラブルな 
PHP アプリケーション
PDF
認証機能で学ぶ Laravel 5 アプリケーション
PDF
VagrantユーザのためのDocker入門
PDF
Twilio API を PHP で触ってみよう
PDF
わかってるフレームワーク Laravel
PDF
Vagrant & Dockerによるイマドキの開発環境構築
PPTX
Ansibleを使ってdockerコンテナをプロビジョニングする
PDF
Azure Websites で作るスケーラブルな PHP アプリケーション
PPTX
Pythonユーザのための構成管理入門 #pyconapac
PDF
コンテナ事例 CircleCI, Cucumber-Chef
PPTX
サーバ側Swift
PPTX
イベント駆動プログラミングとI/O多重化
PPTX
OpenShift from Easy way to Hard ? Way
PDF
さくらのインフラコード
PDF
いまどきのPHP
PDF
Vagrant+Ansibleで検証環境を簡単構築
PDF
第1回 一撃サーバー構築シェルスクリプト勉強会
PPTX
開発環境をVagrantからdockerに移行してみた
PPTX
Dockerを使ってみよう
PPTX
Alpine linuxを触ってみよう
Heroku で作る
スケーラブルな 
PHP アプリケーション
認証機能で学ぶ Laravel 5 アプリケーション
VagrantユーザのためのDocker入門
Twilio API を PHP で触ってみよう
わかってるフレームワーク Laravel
Vagrant & Dockerによるイマドキの開発環境構築
Ansibleを使ってdockerコンテナをプロビジョニングする
Azure Websites で作るスケーラブルな PHP アプリケーション
Pythonユーザのための構成管理入門 #pyconapac
コンテナ事例 CircleCI, Cucumber-Chef
サーバ側Swift
イベント駆動プログラミングとI/O多重化
OpenShift from Easy way to Hard ? Way
さくらのインフラコード
いまどきのPHP
Vagrant+Ansibleで検証環境を簡単構築
第1回 一撃サーバー構築シェルスクリプト勉強会
開発環境をVagrantからdockerに移行してみた
Dockerを使ってみよう
Alpine linuxを触ってみよう
Ad

Viewers also liked (20)

PDF
とあるエンジニアが旅に出てみた
PPTX
Introducing company
PPTX
UE4で実現できた理想のゲーム開発ワークフロー
PPTX
50分でわかるブループリントについて
PPTX
Digital Marketing
PDF
Tutorial for the ReportLinker App
DOCX
من اجلك
PDF
char32_tとXpressiveと
PDF
Nvidia GTC 2014 Talk
PPTX
Ultizing Online Space: Virtual Fairs and Online Conversion Tools (with poll r...
PPTX
Chrome-eject がこの先生きのこるには
PPTX
Html5 history api
PPTX
Escritura creativa
PDF
Kuidas Targad Juhid Tegutsevad 2007
PPTX
Youth Participation - learned lessons from Sensoa's history
PPTX
Social Media Success in International Student Recruitment
PPTX
מחדד 05.03
PDF
だいすきStoryboard - #potatotips (iOS/Android開発Tips共有会) 第7回
PPTX
جای خالی مدیر ارشد برند در شرکت های ایرانی
PDF
Dependency management with Composer
とあるエンジニアが旅に出てみた
Introducing company
UE4で実現できた理想のゲーム開発ワークフロー
50分でわかるブループリントについて
Digital Marketing
Tutorial for the ReportLinker App
من اجلك
char32_tとXpressiveと
Nvidia GTC 2014 Talk
Ultizing Online Space: Virtual Fairs and Online Conversion Tools (with poll r...
Chrome-eject がこの先生きのこるには
Html5 history api
Escritura creativa
Kuidas Targad Juhid Tegutsevad 2007
Youth Participation - learned lessons from Sensoa's history
Social Media Success in International Student Recruitment
מחדד 05.03
だいすきStoryboard - #potatotips (iOS/Android開発Tips共有会) 第7回
جای خالی مدیر ارشد برند در شرکت های ایرانی
Dependency management with Composer
Ad

Similar to Vagrant を Web開発環境に使う (20)

PDF
Vagrantと網元で開発環境を作ってみよう
PDF
Vagrant intro
PDF
ローカル開発環境の構築をしよう VirtualBox + Vagrant
PDF
Vagrant でお手軽開発環境
PDF
仮想マシンを使った開発環境の簡単共有方法
PPTX
勉強会0614 vagrant
PPTX
3分間 開発環境クッキング 2012.07 #pyfes
PDF
仮想マシンざっくり解説と実践Vagrant | StaticPress × S3 × Vagrant 勉強会
PDF
松本Linux勉強会 vagrant入門
PPTX
Vagrant×Rails セットアップ講習会資料
PDF
Vagrant+Chef
PPTX
2017/04/12 mac/win対応の 仮想環境構築で複数インスタンスをぶん回せ!
PPTX
Vagrant chef
PDF
仮想環境によるLinux
PPTX
Word bench富山 vagrantやってみよう
PDF
Vagrant+virtualboxを使ってみよう
PDF
Vagrant + VirtualBox + Chef を使った環境構築方法について
ODP
"Up" with vagrant and docker
PDF
Vagrant chef
PPTX
Transnet.+ lunch mt #1
Vagrantと網元で開発環境を作ってみよう
Vagrant intro
ローカル開発環境の構築をしよう VirtualBox + Vagrant
Vagrant でお手軽開発環境
仮想マシンを使った開発環境の簡単共有方法
勉強会0614 vagrant
3分間 開発環境クッキング 2012.07 #pyfes
仮想マシンざっくり解説と実践Vagrant | StaticPress × S3 × Vagrant 勉強会
松本Linux勉強会 vagrant入門
Vagrant×Rails セットアップ講習会資料
Vagrant+Chef
2017/04/12 mac/win対応の 仮想環境構築で複数インスタンスをぶん回せ!
Vagrant chef
仮想環境によるLinux
Word bench富山 vagrantやってみよう
Vagrant+virtualboxを使ってみよう
Vagrant + VirtualBox + Chef を使った環境構築方法について
"Up" with vagrant and docker
Vagrant chef
Transnet.+ lunch mt #1

More from Masashi Shinbara (16)

PDF
日本語消えたスライド
PDF
Twilio入門 -Web アプリ編-
PDF
いまどきのPHP開発現場 -2015年秋-
PDF
レイヤードアーキテクチャを意識した PHPアプリケーションの構築 ver2
PDF
先取り!PHP 7 と WordPress
PDF
Twilio を使えば簡単にできる アプリケーションと電話/SMS連携
PDF
レイヤードアーキテクチャを意識したPHPアプリケーションの構築
PDF
How to learn Laravel5 application from Authentication
PDF
PHPコードではなく PHPコードの「書き方」を知る
PDF
Laravel ユーザなら知っておくべきAuthオートログイン
PDF
キャラ立ちしたエンジニアになる!
PDF
Composer 再入門
PDF
PHP 5.5 Zend OPcache
PDF
サーバの防災訓練
PDF
Kansai PHP Users Group 2012年活動報告
KEY
10分で分かる最近のCakePHP
日本語消えたスライド
Twilio入門 -Web アプリ編-
いまどきのPHP開発現場 -2015年秋-
レイヤードアーキテクチャを意識した PHPアプリケーションの構築 ver2
先取り!PHP 7 と WordPress
Twilio を使えば簡単にできる アプリケーションと電話/SMS連携
レイヤードアーキテクチャを意識したPHPアプリケーションの構築
How to learn Laravel5 application from Authentication
PHPコードではなく PHPコードの「書き方」を知る
Laravel ユーザなら知っておくべきAuthオートログイン
キャラ立ちしたエンジニアになる!
Composer 再入門
PHP 5.5 Zend OPcache
サーバの防災訓練
Kansai PHP Users Group 2012年活動報告
10分で分かる最近のCakePHP

Vagrant を Web開発環境に使う

  • 1. 2013/07/06 shin1x1 第2回 JAWS-UG神戸 もう XAMPP / MAMP はいらない! Vagrant を Web開発環境に使う
  • 2. @shin1x1 (c) 2013 Masashi Shinbara @shin1x1 Shin x blog http://www.1x1.jp/blog/ PHP / DevOps / AWS / Varnish / Fabric / Chef
  • 3. 開発環境 (c) 2013 Masashi Shinbara @shin1x1 Web開発あるある
  • 4. エンジニアSさん (c) 2013 Masashi Shinbara @shin1x1 • Macbook Air で開発 • Apache / PHP / DB • 複数案件を一台で
  • 5. エンジニアSさん (c) 2013 Masashi Shinbara @shin1x1 1162 <VirtualHost *:80> 1163 ServerName candycane.local 1164 DocumentRoot "/Users/shin/sandbox/demo/candycane/app/webroot" 1165 </VirtualHost> 1166 1167 <VirtualHost *:80> 1168 ServerName demo.local 1169 DocumentRoot "/Users/shin/sandbox/demo/20130601_phpcon" 1170 php_value vld.active 1 1171 </VirtualHost> 1172 1173 <VirtualHost *:80> 1174 ServerName project1.local 1175 DocumentRoot "/Users/shin/project1/app/webroot" 1176 </VirtualHost> 1177 1178 <VirtualHost *:80> 1179 ServerName project2.local 1180 DocumentRoot "/Users/shin/project2/app/webroot" 1181 </VirtualHost>
  • 6. エンジニアSさん (c) 2013 Masashi Shinbara @shin1x1 1162 <VirtualHost *:80> 1163 ServerName candycane.local 1164 DocumentRoot "/Users/shin/sandbox/demo/candycane/app/webroot" 1165 </VirtualHost> 1166 1167 <VirtualHost *:80> 1168 ServerName demo.local 1169 DocumentRoot "/Users/shin/sandbox/demo/20130601_phpcon" 1170 php_value vld.active 1 1171 </VirtualHost> 1172 1173 <VirtualHost *:80> 1174 ServerName project1.local 1175 DocumentRoot "/Users/shin/project1/app/webroot" 1176 </VirtualHost> 1177 1178 <VirtualHost *:80> 1179 ServerName project2.local 1180 DocumentRoot "/Users/shin/project2/app/webroot" 1181 </VirtualHost> 溢れる VirtualHost
  • 7. とある開発チームA (c) 2013 Masashi Shinbara @shin1x1 • Macbook / Windows で開発 • Apache / PHP / DB • チームで開発
  • 8. とある開発チームA (c) 2013 Masashi Shinbara @shin1x1 あれ?動かない。 何か変なコード書いた? こっちは動いてるよ。 モジュール入れないとダメだよ。
  • 9. とある開発チームA (c) 2013 Masashi Shinbara @shin1x1 あれ?動かない。 何か変なコード書いた? こっちは動いてるよ。 モジュール入れないとダメだよ。 俺の環境では動く
  • 10. WebデザイナーBさん (c) 2013 Masashi Shinbara @shin1x1 • WordPressのデザイン • XAMPPをインストール •でもなんだか動かない。。。
  • 11. (c) 2013 Masashi Shinbara @shin1x1 WebデザイナーBさん
  • 12. (c) 2013 Masashi Shinbara @shin1x1 WebデザイナーBさん Port 80 は 俺のモノ
  • 14. Vagrant (c) 2013 Masashi Shinbara @shin1x1 • 誰でも全く同じ環境を構築できる • 構成はコードで書く • 環境構築はコマンド一つだけ
  • 15. demo1 (c) 2013 Masashi Shinbara @shin1x1 httpd サーバ
  • 16. demo1 (c) 2013 Masashi Shinbara @shin1x1 • VMイメージ取得 • VM起動 • プロビジョニング • VM終了
  • 17. demo1 (c) 2013 Masashi Shinbara @shin1x1 $ vagrant init $ ls Vagrantfile
  • 18. (c) 2013 Masashi Shinbara @shin1x1 # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| config.vm.box = "centos64_ja" config.vm.provider :virtualbox do |v| v.gui = true end config.vm.network :private_network, ip: "192.168.33.100" config.vm.provision :shell, :inline => "yum install -y httpd && /sbin/service httpd start" end $ vim Vagrantfile demo1
  • 19. (c) 2013 Masashi Shinbara @shin1x1 # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| config.vm.box = "centos64_ja" config.vm.provider :virtualbox do |v| v.gui = true end config.vm.network :private_network, ip: "192.168.33.100" config.vm.provision :shell, :inline => "yum install -y httpd && /sbin/service httpd start" end $ vim Vagrantfile demo1 VMイメージ
  • 20. (c) 2013 Masashi Shinbara @shin1x1 # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| config.vm.box = "centos64_ja" config.vm.provider :virtualbox do |v| v.gui = true end config.vm.network :private_network, ip: "192.168.33.100" config.vm.provision :shell, :inline => "yum install -y httpd && /sbin/service httpd start" end $ vim Vagrantfile demo1 GUI表示
  • 21. (c) 2013 Masashi Shinbara @shin1x1 # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| config.vm.box = "centos64_ja" config.vm.provider :virtualbox do |v| v.gui = true end config.vm.network :private_network, ip: "192.168.33.100" config.vm.provision :shell, :inline => "yum install -y httpd && /sbin/service httpd start" end $ vim Vagrantfile demo1 IPアドレス
  • 22. (c) 2013 Masashi Shinbara @shin1x1 # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| config.vm.box = "centos64_ja" config.vm.provider :virtualbox do |v| v.gui = true end config.vm.network :private_network, ip: "192.168.33.100" config.vm.provision :shell, :inline => "yum install -y httpd && /sbin/service httpd start" end $ vim Vagrantfile demo1 プロビジョニング Chef / Puppet / Shell
  • 23. (c) 2013 Masashi Shinbara @shin1x1 $ vagrant up Bringing machine 'default' up with 'virtualbox' provider... [default] Importing base box 'centos64_ja'... demo1
  • 24. (c) 2013 Masashi Shinbara @shin1x1 [default] Running provisioner: shell... [default] Running: inline script Loaded plugins: fastestmirror Determining fastest mirrors * base: ftp.iij.ad.jp * extras: ftp.iij.ad.jp * updates: ftp.iij.ad.jp Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.2.15-28.el6.centos will be installed demo1
  • 25. (c) 2013 Masashi Shinbara @shin1x1 $ open http://192.168.33.100/ demo1
  • 26. (c) 2013 Masashi Shinbara @shin1x1 $ vagrant ssh Welcome to your Vagrant-built virtual machine. [vagrant@localhost ~]$ $ vagrant destory Are you sure you want to destroy the 'default' VM? [y/N] y [default] Forcing shutdown of VM... Connection to 127.0.0.1 closed by remote host. [default] Destroying VM and associated drives... demo1
  • 27. demo2 (c) 2013 Masashi Shinbara @shin1x1 Wordpress
  • 28. Varying Vagrant Vagrants (c) 2013 Masashi Shinbara @shin1x1 • github で公開 https://github.com/10up/varying-vagrant-vagrants • WordPress 環境を構築 • 20 のコンポーネントを インストール!
  • 29. Varying Vagrant Vagrants (c) 2013 Masashi Shinbara @shin1x1 Ubuntu 12.04 LTS (Precise Pangolin) subversion 1.7.9 nginx 1.4.1 ngrep mysql 5.5.31 dos2unix php-fpm 5.4.15 WordPress 3.5.2 memcached 1.4.13 WordPress trunk PHP memcache extension 3.0.6 WP-CLI xdebug 2.2.1 WordPress Unit Tests PHPUnit 3.7.21 Composer ack-grep 2.04 phpMemcachedAdmin 1.2.2 BETA git 1.8.3 phpMyAdmin 4.0.3
  • 30. (c) 2013 Masashi Shinbara @shin1x1 $ git clone https://github.com/10up/ varying-vagrant-vagrants.git $ cd varying-vagrant-vagrants $ vagrant up Varying Vagrant Vagrants
  • 31. (c) 2013 Masashi Shinbara @shin1x1 $ open http://192.168.50.4/ demo2
  • 32. (c) 2013 Masashi Shinbara @shin1x1 $ open http://local.wordpress.dev/ demo2
  • 33. 開発サーバ構築の流れ (c) 2013 Masashi Shinbara @shin1x1 1. Vagrantfile 書く 2. プロビジョニング書く 3. vagrant up で構築 4. vagrant destory で破棄 (vagrant reload で再構築)
  • 34. 従来のツールに例えると (c) 2013 Masashi Shinbara @shin1x1 Vagrantfile = Makefile vagrant up = make $ vim Makefile $ make $ vim Vagrantfile $ vagrant up
  • 35. Vagrant 良いところ (c) 2013 Masashi Shinbara @shin1x1 • ホストとサーバでディレクトリ共有 => 開発は IDE で、実行はサーバで • IPアドレス、マシンリソース定義 • VCS(Git等) で差分管理 • 構築、配布、共有が楽
  • 36. Sahara Plugin (c) 2013 Masashi Shinbara @shin1x1 • Vagrant Plugin https://github.com/jedi4ever/sahara • DB の ROLLBACK のように サーバの状態が戻せる
  • 37. Sahara Plugin (c) 2013 Masashi Shinbara @shin1x1 $ vagrant plugin install sahara • インストール
  • 38. Sahara Plugin (c) 2013 Masashi Shinbara @shin1x1 $ vagrant sandbox on • sandbox モード開始 = BEGIN; $ vagrant sandbox rollback • 元に戻す = ROLLBACK; $ vagrant sandbox commit • 変更確定 = COMMIT; $ vagrant sandbox off • sandbox モード終了
  • 39. Sahara Plugin (c) 2013 Masashi Shinbara @shin1x1 $ vagrant sandbox on vagrant sandbox on 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%... 100% $ vagrant ssh [vagrant@localhost ~]$ sudo rm -rf /bin [vagrant@localhost ~]$ ls -bash: ls: コマンドが見つかりません [vagrant@localhost ~]$ exit
  • 40. Sahara Plugin (c) 2013 Masashi Shinbara @shin1x1 $ vagrant sandbox rollback 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%... 100% 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%... 100% $ vagrant ssh [vagrant@localhost ~]$ ls
  • 41. おすすめ1 (c) 2013 Masashi Shinbara @shin1x1 http://docs.vagrantup.com/v2/
  • 42. おすすめ2 (c) 2013 Masashi Shinbara @shin1x1 http://www.amazon.co.jp/dp/1449335837
  • 43. Summary (c) 2013 Masashi Shinbara @shin1x1 • 誰でも全く同じ環境を構築できる • 構成はコードで書く => Vagrantfile • 環境構築はコマンド一つだけ => vagrant up
  • 44. @shin1x1 (c) 2013 Masashi Shinbara @shin1x1