Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Dockerで作るPHP開発環境(入門編)

Takashi Nojima
September 12, 2018

 Dockerで作るPHP開発環境(入門編)

2018.09.12 博多TECH塾

デモ・サンプルコード
https://github.com/nojimage/hakata-tech-php-docker/tree/master/vol0

Takashi Nojima

September 12, 2018
Tweet

More Decks by Takashi Nojima

Other Decks in Technology

Transcript

  1. ϋʔυ΢ΣΞ ϗετ04 Ծ૝Խιϑτ ήετ04 ϛυϧ΢ΣΞ ΞϓϦ ήετ04 ϛυϧ΢ΣΞ ΞϓϦ ϋʔυ΢ΣΞ

    ϗετ04 %PDLFS&OHJOF Ծ૝Ϛγϯ ίϯςφ ϛυϧ΢ΣΞ ΞϓϦ ϛυϧ΢ΣΞ ΞϓϦ Ծ૝Ϛγϯ ίϯςφ Ծ૝ϚγϯͱDockerͷҧ͍
  2. Docker for Windows/Mac ͱ Docker Machine ͷҧ͍ ϋʔυ΢ΣΞ 8JOEPXTNBD04 )ZQFS7YIZWF

    ϋʔυ΢ΣΞ ϗετ04 %PDLFS&OHJOF %PDLFSGPS8JOEPXT.BD %PDLFS.BDIJOF ϛυϧ΢ΣΞ ΞϓϦ ϛυϧ΢ΣΞ ΞϓϦ Ծ૝Խιϑτ ήετ04 %PDLFS&OHJOF ϛυϧ΢ΣΞ ΞϓϦ ϛυϧ΢ΣΞ ΞϓϦ
  3. Docker DesktopΛΠϯετʔϧ ‣ Πϯετʔϧޙɺίϯιʔϧ͔ΒEPDLFSWFSTJPO ͱଧͬͯىಈΛ֬ೝ $ docker version Client: Version:

    18.06.1-ce API version: 1.38 Go version: go1.10.3 Git commit: e68fc7a Built: Tue Aug 21 17:21:31 2018 OS/Arch: darwin/amd64 Experimental: false Server: Engine: Version: 18.06.1-ce API version: 1.38 (minimum version 1.12) Go version: go1.10.3 Git commit: e68fc7a Built: Tue Aug 21 17:29:02 2018 OS/Arch: linux/amd64 Experimental: true ClientͱServer྆ํͷόʔδϣϯ͕ දࣔ͞Ε͍ͯΕ͹OK
  4. PHPެࣜΠϝʔδ ‣ 1)1ͷΠϝʔδʹ͸৭ʑͳछྨ͕͋Δ ‣ DMJ ‣ GQN ‣ BQBDIF ‣

    DMJBMQJOF ‣ GQNBMQJOF ‣ DMJBMQJOF ࠷ॳͷ਺ࣈ͸1)1όʔδϣϯ DMJ$-* ίϚϯυϥΠϯ ൛ GQN1)1'1.൛ BQBDIF"QBDIFIUUQEಉࠝ൛ [UT;54ʢ;FOE5ISFBE4BGFUZʣରԠ൛ ௨ৗ͸%FCJBOϕʔε BMQJOF͕ͭ͘ͱΑΓܰྔͳ"MQJOF-JOVYϕʔε
  5. PHPίϯςφΛىಈ͢Δ docker run \ --rm \ -p 8000:80 \ -v

    "$PWD":/var/www/html \ php:7.2-apache ˡίϯςφΛىಈ ˡίϯςφΛऴྃͨ͠Β࡟আ͢Δ ˡίϯςφͷϙʔτΛϗετͷʹׂΓ౰ͯ ˡݱࡏͷσΟϨΫτϦΛWBSXXXIUNMʹϚ΢ϯτ ˡQIQBQBDIFͷΠϝʔδ͔Β࣮ߦ IUUQMPDBMIPTUͰΞΫηεͰ͖Δ
  6. CLIͰPHPΛىಈ͢Δ docker run \ --rm \ -v "$PWD":/var/www/html \ php:7.2-apache

    \ php hello.php ˡίϯςφΛىಈ ˡίϯςφΛऴྃͨ͠Β࡟আ͢Δ ˡݱࡏͷσΟϨΫτϦΛWBSXXXIUNMʹϚ΢ϯτ ˡQIQBQBDIFͷΠϝʔδ͔Β࣮ߦ ˡQIQίϚϯυͰIFMMPQIQΛ࣮ߦ
  7. GD֦ுΛΠϯετʔϧ FROM php:7.2-apache RUN apt-get update \ && apt-get install

    -y \ libfreetype6-dev \ libjpeg62-turbo-dev \ libpng-dev \ && docker-php-ext-configure gd \ --with-freetype-dir=/usr/include/ \ --with-jpeg-dir=/usr/include/ \ && docker-php-ext-install gd ˡQIQBQBDIFΛϕʔεʹ͢Δ ˡBQUύοέʔδΞοϓσʔτ ˡ(%ʹඞཁͳύοέʔδΛΠϯετʔϧ ˡ(%֦ுͷϏϧυΦϓγϣϯΛࢦఆ ˡ(%֦ுΛΠϯετʔϧ