LoginSignup
9

More than 5 years have passed since last update.

Vagrant + VirtualBoxでLAMP環境構築(Windows版)

Last updated at Posted at 2014-12-03

経緯

Windows8.1上で、Vagrant + VirtualBoxで仮想環境を構築した。
LAMP環境を作っていく。

環境構築

Chef

Chefで環境構築する

vagrant-omnibusインストール

Chefが入ってなかった、インストールしてくれるPlugin。
以下、リンクのREADMEにしたがってインストール。

C:\dev>vagrant plugin install vagrant-omnibus
Installing the 'vagrant-omnibus' plugin. This can take a few minutes...
Installed the plugin 'vagrant-omnibus (1.4.1)'!

レシピ作成

フォルダを作っておく

C:\dev>mkdir cookbooks\httpd\recipes
C:\dev>mkdir cookbooks\mysql\recipes
C:\dev>mkdir cookbooks\php\recipes
C:\dev>mkdir cookbooks\remi\recipes

以下を作成

defaut.rb
yum_package "httpd" do
  action :install
end

service "httpd" do
  action :start
end
defaut.rb
yum_package "mysql-server" do
  action :install
end

service "mysqld" do
  action :start
end
defaut.rb
%w[
  php
  php-pdo
  php-mbstring
  php-mysqlnd
].each do |pkg|
  package "#{pkg}" do
    action :install
    options '--enablerepo=remi-php55'
  end
end
defaut.rb
remote_file "#{Chef::Config[:file_cache_path]}/remi-release-6.rpm" do
  source "http://rpms.famillecollet.com/enterprise/remi-release-6.rpm"
  action :create
end
rpm_package "remi-release-6" do
  source "#{Chef::Config[:file_cache_path]}/remi-release-6.rpm"
  action :install
end

Vagrantfile編集

Vagrantfile
config.omnibus.chef_version = :latest
config.vm.provision "chef_solo" do |chef|
  chef.cookbooks_path = "./site-cookbooks"
  chef.add_recipe "remi"
  chef.add_recipe "httpd"
  chef.add_recipe "mysql"
  chef.add_recipe "php"
end

起動

一度VMを壊す。

C:\dev>vagrant destroy

再度立ち上げ

C:\dev>vagrant up

確認

念のためバージョン確認しておく。

$ httpd -v
Server version: Apache/2.2.15 (Unix)
Server built:   Oct 16 2014 14:48:21

$ mysql -V
mysql  Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1

$ php -v
PHP 5.5.19 (cli) (built: Nov 16 2014 09:53:48)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies

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
9