Lock in $30 Savings on PRO—Offer Ends Soon! ⏳

CakePHPで学ぶ継続的インテグレーション ハンズオン@大阪 環境構築編

Kaz Watanabe
November 01, 2014

CakePHPで学ぶ継続的インテグレーション ハンズオン@大阪 環境構築編

環境構築編

Kaz Watanabe

November 01, 2014
Tweet

More Decks by Kaz Watanabe

Other Decks in Programming

Transcript

  1. WHO? • Θͨͳ΂͔ͣͻΖ(@kaz_29) • ߹ಉձࣾ decr (decr.jp) • PHP(CakePHP)ͰWebΞϓϦ։ൃ •

    Πϯϑϥߏஙɾӡ༻ • iOSΞϓϦ։ൃ #beer #iosdev #cakephp #cat #camp! #golf #chef #vagrant
  2. ඞཁͳ΋ͷ • VitrtualBox - https://www.virtualbox.org/ • Vagrant - https://www.vagrantup.com/ •

    ChefDK - https://downloads.getchef.com/chef-dk/ ग़དྷΔ͚ͩ࠷৽Λ࢖͏
  3. Vagrantfileͷղઆ … config.vm.define :develop do |develop| develop.omnibus.chef_version = :latest develop.vm.hostname

    = "develop" develop.vm.box = "opscode-ubuntu-14.04" develop.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/ vagrant/virtualbox/opscode_ubuntu-14.04_chef-provisionerless.box" develop.vm.network :private_network, ip: "192.168.33.10" ! develop.vm.synced_folder "application", "/var/www/application/ current", id: "vagrant-root", :nfs => false, :owner => "vagrant", :group => "www-data", :mount_options => ["dmode=775,fmode=775"] …
  4. Vagrantfileͷղઆ … develop.vm.provision :chef_solo do |chef| chef.log_level = "debug" chef.cookbooks_path

    = "./cookbooks" chef.json = { nginx: { docroot: { owner: "vagrant", group: "vagrant", path: "/var/www/application/current/app/webroot", force_create: true }, default: { fastcgi_params: { CAKE_ENV: "development" } }, test: { available: true, fastcgi_params: { CAKE_ENV: "test" } } } } chef.run_list = %w[ recipe[apt] recipe[phpenv::default] recipe[phpenv::composer] recipe[phpenv::develop] recipe[capistrano] ] end …
  5. MYSQL PWΛઃఆ ! $ vagrant ssh develop mysql -uroot -ppassword

    ! GRANT ALL PRIVILEGES ON *.* TO 'webapp'@'%' identified by 'passw0rd' WITH GRANT OPTION; FLUSH PRIVILEGES; CREATE DATABASE blog default character set utf8; CREATE DATABASE test_blog default character set utf8; ! $ vagrant ssh ci $ vagrant ssh deploy
  6. 伴Λ࡞ͬͯొ࿥ ! $ vagrant ssh develop $ ssh-keygen Generating public/private

    rsa key pair. Enter file in which to save the key (/home/vagrant/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: … ! $ cat ~/.ssh/id_rsa.pub ެ։伴Λίϐʔ
  7. ΞϓϦέʔγϣϯΛॳظԽ ! $ vagrant ssh develop $ cd /var/www/application/current $

    rm -rf * $ git clone git://github.com/decr/blogapp.git . (<=υοτ) $ git checkout -b step1 origin/step1 $ cd /var/www/application/current/app $ composer install --dev