Click here to load reader
Upload
masashi-shinbara
View
1.540
Download
5
Embed Size (px)
DESCRIPTION
2013/10/26 Innovation EGG
Citation preview
2013/10/26 shin1x1
Innovation EGG
Vagrant で PHP 開発環境を作る
ハンズオン準備
(c) 2013 Masashi Shinbara @shin1x1
USBメモリから ファイルコピー
Agenda
(c) 2013 Masashi Shinbara @shin1x1
• Vagrant とは • ハンズオン • ポイント
PHP開発環境
(c) 2013 Masashi Shinbara @shin1x1
• PHPを直接インストール (ソース, MacPorts, Homebrew etc)
• XAMMP / MAMP • Vagrant
Vagrant?
(c) 2013 Masashi Shinbara @shin1x1
Vagrant
(c) 2013 Masashi Shinbara @shin1x1
• 仮想環境をコマンドで操作 • 構築手順をコードで定義 • OSS(MITライセンス) • VirtualBox との組み合わせ
Vagrantなら
(c) 2013 Masashi Shinbara @shin1x1
• プロジェクト毎に独立した環境を構築 • 他人と全く同じ環境を共有 • ホストPCとは分離された環境を構築
Vagrant 動作イメージ
(c) 2013 Masashi Shinbara @shin1x1
[ホスト] 開発用PC
仮想環境(VirutalBox)Vagrant
(c) 2013 Masashi Shinbara @shin1x1
[ホスト] 開発用PC
仮想環境(VirutalBox)Vagrant
仮想マシン起動
Vagrant 動作イメージ
(c) 2013 Masashi Shinbara @shin1x1
[ホスト] 開発用PC
仮想環境(VirutalBox)Vagrant
[ゲスト] 仮想マシン
Vagrant 動作イメージ
(c) 2013 Masashi Shinbara @shin1x1
[ホスト] 開発用PC
仮想環境(VirutalBox)Vagrant
プロビジョン[ゲスト] 仮想マシン
Vagrant 動作イメージ
(c) 2013 Masashi Shinbara @shin1x1
[ホスト] 開発用PC
仮想環境(VirutalBox)Vagrant
[ゲスト] 仮想マシン
Apache PHP
MySQL / PostgreSQL
Vagrant 動作イメージ
(c) 2013 Masashi Shinbara @shin1x1
[ホスト] 開発用PC
仮想環境(VirutalBox)Vagrant
仮想マシン破棄[ゲスト] 仮想マシン
Vagrant 動作イメージ
(c) 2013 Masashi Shinbara @shin1x1
[ホスト] 開発用PC
仮想環境(VirutalBox)Vagrant
Vagrant 動作イメージ
Vagrantで作るPHP開発環境
(c) 2013 Masashi Shinbara @shin1x1
http://www.slideshare.net/shin1x1/xampp-mamp-vagrant-php
Vagrant 覚えておきたい用語
(c) 2013 Masashi Shinbara @shin1x1
•Boxファイル => 仮想マシンイメージファイル
•Vagrantfile => 仮想マシン構築設定
•vagrantコマンド => 全ての操作はこのコマンドで
(c) 2013 Masashi Shinbara @shin1x1
ハンズオン
(c) 2013 Masashi Shinbara @shin1x1
流れ
1. USBメモリから必要なファイルコピー
2. インストール、仮想マシン起動 (手順は、Gist を参照)
3. 上手く動いたら tweet (#phpkansai)
(c) 2013 Masashi Shinbara @shin1x1
https://gist.github.com/shin1x1/7114143
手順資料
#phpkansai
vagrant 主なコマンド
(c) 2013 Masashi Shinbara @shin1x1
• 仮想サーバ起動$ vagrant up
• 仮想サーバへ SSH ログイン$ vagrant ssh
• 仮想サーバ停止$ vagrant halt
• 仮想サーバ停止+破棄$ vagrant destroy
(c) 2013 Masashi Shinbara @shin1x1
ポイント
(c) 2013 Masashi Shinbara @shin1x1
•構築する仮想マシンの内容を記述 •Ruby •分かる人が書けば良い
Vagrantfile
(c) 2013 Masashi Shinbara @shin1x1
•ホストPCのディレクトリと 仮想サーバのディレクトリを同期
•開発はホストPCで、 実行は仮想サーバで
•PhpStormやEclipseで開発可能
synced_folder
(c) 2013 Masashi Shinbara @shin1x1
synced_folder
$ ls /path/to/doctoot! index.php sample.php
$ ls /share/doctoot! index.php sample.php
�� �������������
ホストPC
仮想マシン
(c) 2013 Masashi Shinbara @shin1x1
synced_folder
<?php!$foo = Foo::foo();
<?php!$foo = Foo::foo();
�� �������������
ホストPC
仮想マシン
PHPコード変更
自動で同期
(c) 2013 Masashi Shinbara @shin1x1
• プロジェクトリポジトリへ追加 • プロジェクト毎に作る • 作業が終わったら、仮想マシンは停止
プロジェクトへの適用
参考2
(c) 2013 Masashi Shinbara @shin1x1
http://www.amazon.co.jp/dp/1449335837
参考3
(c) 2013 Masashi Shinbara @shin1x1
http://www.amazon.co.jp/dp/B00F418SQ8
@shin1x1
(c) 2013 Masashi Shinbara @shin1x1
(c) 2013 Masashi Shinbara @shin1x1
One more thing
(c) 2013 Masashi Shinbara @shin1x1
黒い画面はいや!
(c) 2013 Masashi Shinbara @shin1x1
絶賛開発中 (近日公開予定)
Mac OS X 用 GUIアプリ
VagrantX