Mac・Windows共通のPHP開発環境

Ad764891660aca92abb3ae39879b1b36?s=47 komagata
April 28, 2015

 Mac・Windows共通のPHP開発環境

vagrant + ansibleでPHP開発環境

Ad764891660aca92abb3ae39879b1b36?s=128

komagata

April 28, 2015
Tweet

Transcript

  1. .BDɾ8JOEPXTڞ௨ͷ
 1)1։ൃ؀ڥ ۨܗਅ޾@߹ಉձࣾϑΟϤϧυ
 Twitter: @komagata
 blog: http://docs.komagata.org

  2. ϨΨγʔ1)1ͱ೔ʑઓ͍ͬͯ·͢ http://docs.komagata.org/5241

  3. • Ϩϯλϧαʔόʔ • Windowsɹ • Subversionɹ • ڞ௨։ൃαʔόʔ • खಈσϓϩΠ

    • खಈςετ ϨΨγʔ1)1։ൃ؀ڥ
  4. • ϨϯλϧαʔόʔɹˠɹΫϥ΢υ • WindowsɹˠɹMac or Linux • SubversionɹˠɹGithub • ڞ௨։ൃαʔόʔɹˠɹݸਓ։ൃ؀ڥ

    • खಈσϓϩΠɹˠɹܧଓతσϓϩΠ • खಈςετɹˠɹࣗಈςετ ϨΨγʔ1)1։ൃ؀ڥ ͜Μͳײ͡ʹม͍͖͍͑ͯͨΑͶ
  5. Կ͔ΒखΛ͚ͭΔʁ

  6. ݸਓ։ൃ؀ڥ͔ΒखΛ෇͚ͨ wڞ௨։ൃαʔόʔ͸༧૝Ҏ্ʹ΍͔͍ͬ w ίϯϑϦΫτ
 ʮ͜Ε͔Βࢲ͕৮ΔͷͰΈͳ͞Μ"""αΠτ৮Βͳ͍ͳ͍Ͱ͍ͩ͘͞ʯ w HJUʹͯ̍͠ਓ͕CSBODIมߋ͢ΔͱશһCSBODI͕มΘΔ w ωοτϫʔΫӽ͠ͷTWOPOTBNCB͍͢͝஗͍ w

    ࣾ಺͔Β͔͠ݟ͑ͳ͍ w %#ͷ಺༰͕ൿ఻ͷλϨԽ w ͍Βͳ͍ϑΝΠϧͨ͘͞Μ
  7. WBHSBOU BOTJCMFͰ ααͬͱ࡞Γ·ͨ͠

  8. ӕͰ͢ windowsϚγϯങ͍·ͨ͠ɻ

  9. ͦΜͳαΫοͱͰ͖ͯͳ͍ windowsϚγϯങ͍·ͨ͠ɻ ΤΠεʔε

  10. TIJOYCMPH͸ਆ vagrant΍ansibleʹ͍ͭͯ͸@shin1x1͞Μͷϒϩάݟͨ΄͏͕ྑ͍Ͱ͢

  11. XJONBD BOTJCMFͰͷ 1)1։ൃ؀ڥͷίπ ʢ˺ϋϚΓͲ͜Ζʣ

  12. WBHSBOU Vagrant.configure(2) do |config| config.vm.box = "chef/centos-6.6" config.vm.network "private_network", ip:

    "192.168.33.10" config.vm.provision "shell", inline: <<-SHELL yum -y install epel-release yum -y install ansible ansible-playbook /vagrant/vagrant.yml --connection=local SHELL end ௚઀ansibleΛ࢖ΘͣɺshellͰansibleΛΠϯετʔϧͯ͠ ࣗ෼ࣗ਎Λprovisionɻ ʢwindows൛ansibleແ͍ͷͰʣ
  13. BOTJCMF VagrantfileͱplaybookΛಉ͡reposͰ؅ཧ

  14. େྔαΠτ໰୊ ؅ཧ͍ͯ͠ΔαΠτ͕਺े͋ΔͷͰɺ؀ڥΛ࡞Δͷ͕ େมɻ ྫʣ 1.VirtualHostͷઃఆΛ௥Ճ͢Δ 2.HostsʹυϝΠϯɾIPΛઃఆ͢Δ αΠτ͕૿͑Δͨͼʹશһ͕͜ΕͷઃఆΛ͢Δ

  15. 7JSUVBM%PDVNFOU3PPU NameVirtualHost *:80 <VirtualHost *:80> VirtualDocumentRoot /srv/%0 </VirtualHost> <directory /srv/*>

    Order allow,deny Allow from all </directory> foo.jpͰΞΫηε͞ΕͨΒ/srv/foo.jpΛDocumentRootͱ͢Δ ศརػೳɻ
 ʢapacheͷ࿩ɻnginxͰ͸΋ͬͱී௨ʹͰ͖Δʣ
  16. EPDSPPUIBDL NameVirtualHost *:80 <VirtualHost *:80> VirtualDocumentRoot /srv/%0 php_admin_value auto_prepend_file /srv/set_docroot_hack.php

    </VirtualHost> VirtualDocumentRoot࢖͏ͱPHPͷDOCUMENT_ROOT͕ ਖ਼͘͠ઃఆ͞Εͳ͍໰୊ͷճආɻ
 ʢnginxͰ͸ུ <?php $_SERVER['DOCUMENT_ROOT'] = str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['SCRIPT_FILENAME']);
  17. YJQJPͰWJSUVBMIPTU

  18. YJQJPͰWJSUVBMIPTU DNSઃఆ͍ΒͣͰࣗ༝ʹsubdomain࢖͑Δɻ subdomainʹipΛೖΕΔͱͦΕΛฦ͢ɻ ipͷsubdomainʹԿ͔ೖΕͯ΋ແࢹͯ͘͠ΕΔɻ ͜ΕΛ࢖͑͹virtualboxͷprivate network಺ͷhostʹର ͯ͠΋ઃఆແ͠ʹsubdomainΛউखʹ࡞ΕΔɻ 192.168.33.10.xip.io -> 192.168.33.10

    foo.192.168.33.10.xip.io -> 192.168.33.10 bar.192.168.33.10.xip.io -> 192.168.33.10
  19. XJOEPXTͷ ύοέʔδϚωʔδϟʔ homebrewΈ͍ͨͳ΋ͷɻΫοιศརɻ

  20. DIPDPMBUFZ ඞཁͳ෺͕ҰൃͰͦΖ͏ɻΫοιศརʢೋ౓໨ʣ > @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object

    net.webclient).DownloadString('https://chocolatey.org/ install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin ίϚϯυϓϩϯϓτ͔ΒΠϯετʔϧ > choco install googlechrome firefox curl git virtualbox vagrant -y PowerShellͱ͔NuGetͱ͔windowsͷྲّྀʹैͬͯ ΔͷͰ҆৺ʂ
  21. .BD8JOڞ௨ͷ 1)1։ൃ؀ڥ͕Ͱ͖ͨ $ git clone git@github.com:komagata/php-development.git $ cd php-development $

    vagrant up
  22. ϨΨγʔ1)1վળͷ͝༻໋͸ ฐࣾ·Ͱ

  23. Ҏ্Ͱ͢ɻ ͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ