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

Running Laravel/PHP on AWS (AWS Builders Day Taiwan 2022)

Running Laravel/PHP on AWS (AWS Builders Day Taiwan 2022)

This is a talk presents at AWS Builders Day Taiwan 2022.

## Blog post

- https://www.ernestchiang.com/zh/posts/2022/running-laravel-php-on-aws/

## Outline

- Laravel/PHP
- Virtualization 👉 Containerization 👉 Orchestration
- Amazon ECS
- Laravel on Amazon ECS
- Reference
- Q & A

Ernest Chiang

June 17, 2022
Tweet

More Decks by Ernest Chiang

Other Decks in Programming

Transcript

  1. UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
    © 2022, Amazon Web Services, Inc. or its affiliates.
    © 2022, Amazon Web Services, Inc. or its affiliates.
    在 AWS 上運⾏ Laravel/PHP 容器應⽤程式
    Ernest Chiang
    Director of Product & Technology Integration at PAFERS Tec
    h

    AWS Community Hero

    View full-size slide

  2. UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
    © 2022, Amazon Web Services, Inc. or its affiliates.
    © 2022, Amazon Web Services, Inc. or its affiliates.
    在 AWS 上運⾏ Laravel/PHP 容器應⽤程式
    Ernest Chiang
    Director of Product & Technology Integration at PAFERS Tec
    h

    AWS Community Hero

    View full-size slide

  3. © 2022, Amazon Web Services, Inc. or its affiliates.
    拆.解.整.合.的.旅.⼈
    • PAFERS

    Product & Technology Integration

    • AWS

    Community Hero

    • ex-TSMC

    Process Integration Engineer
    Ernest Chiang
    3

    View full-size slide

  4. PAFERS
    We Build Connected Fitness

    View full-size slide

  5. PAFERS Bluetooth Classic Fitness Consoles


    View full-size slide

  6. Bluetooth Event Europe

    View full-size slide

  7. PAFERS Contributes Industry Knowledge to


    Bluetooth Spec
    https://www.bluetooth.com/specifications/gatt/

    View full-size slide

  8. PAFERS Fitness Services (PFS)


    The integrated products and services for fitness.
    Smart

    Fitness

    Consoles
    Video

    Streaming
    Services
    Gym Management
    Services

    (GMS)
    Training Content

    Services

    (TCS)

    View full-size slide

  9. Global PAFERS Edges Footprints

    View full-size slide

  10. © 2022, Amazon Web Services, Inc. or its affiliates.
    Outline
    ⼤綱
    • Laravel/PHP

    • Virtualization 👉 Containerization 👉 Orchestration

    • Amazon ECS

    • Laravel on Amazon ECS

    • Reference

    • Q & A
    10

    View full-size slide

  11. img src: https://commons.wikimedia.org/wiki/File:Cair_Pavarel.jpg
    Laravel/PHP
    www.ErnestChiang.com
    issues?

    View full-size slide

  12. © 2022, Amazon Web Services, Inc. or its affiliates. 12
    That is Cair Paravel, the castle of the four thrones.

    View full-size slide

  13. © 2022, Amazon Web Services, Inc. or its affiliates.
    從 本機 開始
    13

    View full-size slide

  14. © 2022, Amazon Web Services, Inc. or its affiliates.
    先⼿動,再⾃動。
    14

    View full-size slide

  15. © 2022, Amazon Web Services, Inc. or its affiliates.
    我 👉 開發 👉 程式源碼
    15

    View full-size slide

  16. © 2022, Amazon Web Services, Inc. or its affiliates.
    我 👉 安裝 👉 執⾏環境
    16

    View full-size slide

  17. © 2022, Amazon Web Services, Inc. or its affiliates.
    我 👉 安裝 👉 作業系統
    17

    View full-size slide

  18. © 2022, Amazon Web Services, Inc. or its affiliates.
    我 👉 安裝 👉 ⼀台電腦
    18

    View full-size slide

  19. © 2022, Amazon Web Services, Inc. or its affiliates.
    我 👉 安裝 👉 ⼀台電腦
    我 👉 安裝 👉 作業系統
    我 👉 安裝 👉 執⾏環境
    我 👉 開發 👉 程式源碼
    19
    www.ErnestChiang.com

    View full-size slide

  20. © 2022, Amazon Web Services, Inc. or its affiliates.
    我 👉 安裝 👉 ⼀台電腦 👈 別⼈做的
    我 👉 安裝 👉 作業系統 👈 別⼈做的
    我 👉 安裝 👉 執⾏環境 👈 別⼈做的
    我 👉 開發 👉 程式源碼 👈 ⾃⼰做的
    20
    www.ErnestChiang.com

    View full-size slide

  21. © 2022, Amazon Web Services, Inc. or its affiliates.
    我 👉 安裝 👉 ⼀台電腦
    我 👉 安裝 👉 作業系統
    我 👉 安裝 👉 執⾏環境
    我 👉 開發 👉 程式源碼
    21
    www.ErnestChiang.com

    View full-size slide

  22. © 2022, Amazon Web Services, Inc. or its affiliates.
    在我的電腦上,可以正常執⾏
    22
    www.ErnestChiang.com

    View full-size slide

  23. © 2022, Amazon Web Services, Inc. or its affiliates.
    在同事電腦上,就。很。炸。
    23
    www.ErnestChiang.com

    View full-size slide

  24. © 2022, Amazon Web Services, Inc. or its affiliates.
    就別提部署到量產主機了?!
    24

    View full-size slide

  25. © 2022, Amazon Web Services, Inc. or its affiliates. 25
    www.ErnestChiang.com

    View full-size slide

  26. © 2022, Amazon Web Services, Inc. or its affiliates. 26
    www.ErnestChiang.com

    View full-size slide

  27. © 2022, Amazon Web Services, Inc. or its affiliates.
    所以?將 PHP Code 打包?
    27

    View full-size slide

  28. © 2022, Amazon Web Services, Inc. or its affiliates.
    還是 加上 執⾏環境 ⼀起打包?
    28

    View full-size slide

  29. © 2022, Amazon Web Services, Inc. or its affiliates.
    還是 外加 作業系統 ⼀起打包?
    29

    View full-size slide

  30. © 2022, Amazon Web Services, Inc. or its affiliates.
    好,⾄少我們知道這台電腦不能打包。
    30

    View full-size slide

  31. solution?
    Virtualization
    www.ErnestChiang.com

    View full-size slide

  32. © 2022, Amazon Web Services, Inc. or its affiliates.
    Creating a virtual version of something;
    32

    View full-size slide

  33. © 2022, Amazon Web Services, Inc. or its affiliates.
    Creating a virtual version of something;
    33

    View full-size slide

  34. © 2022, Amazon Web Services, Inc. or its affiliates.
    A hypervisor (or virtual machine monitor, VMM,
    virtualizer) is computer software, firmware or
    hardware that creates and runs virtual machines.
    34

    View full-size slide

  35. © 2022, Amazon Web Services, Inc. or its affiliates. 35
    www.ErnestChiang.com

    View full-size slide

  36. © 2022, Amazon Web Services, Inc. or its affiliates. 36
    www.ErnestChiang.com

    View full-size slide

  37. img src: https://unsplash.com/photos/CJdZ800-Fbs
    part of virtualization
    Containerization
    www.ErnestChiang.com

    View full-size slide

  38. © 2022, Amazon Web Services, Inc. or its affiliates.
    Operating-system-level virtualization, also known
    as containerization, refers to an operating system
    feature in which the kernel allows the existence
    of multiple isolated user-space instances.
    Such instances, called containers, partitions,
    virtual environments (VEs) or jails (FreeBSD jail or
    chroot jail), may look like real computers from the
    point of view of programs running in them.
    38

    View full-size slide

  39. © 2022, Amazon Web Services, Inc. or its affiliates.
    Operating-system-level virtualization, also known
    as containerization, refers to an operating system
    feature in which the kernel allows the existence
    of multiple isolated user-space instances.
    Such instances, called containers, partitions,
    virtual environments (VEs) or jails (FreeBSD jail or
    chroot jail), may look like real computers from the
    point of view of programs running in them.
    39

    View full-size slide

  40. © 2022, Amazon Web Services, Inc. or its affiliates.
    Operating-system-level virtualization, also known
    as containerization, refers to an operating system
    feature in which the kernel allows the existence
    of multiple isolated user-space instances.
    Such instances, called containers, partitions,
    virtual environments (VEs) or jails (FreeBSD jail or
    chroot jail), may look like real computers from the
    point of view of programs running in them.
    40

    View full-size slide

  41. © 2022, Amazon Web Services, Inc. or its affiliates.
    Operating-system-level virtualization, also known
    as containerization, refers to an operating system
    feature in which the kernel allows the existence
    of multiple isolated user-space instances.
    Such instances, called containers, partitions,
    virtual environments (VEs) or jails (FreeBSD jail or
    chroot jail), may look like real computers from the
    point of view of programs running in them.
    41

    View full-size slide

  42. © 2022, Amazon Web Services, Inc. or its affiliates. 42
    www.ErnestChiang.com

    View full-size slide

  43. © 2022, Amazon Web Services, Inc. or its affiliates. 43
    www.ErnestChiang.com

    View full-size slide

  44. © 2022, Amazon Web Services, Inc. or its affiliates. 44
    www.ErnestChiang.com

    View full-size slide

  45. © 2022, Amazon Web Services, Inc. or its affiliates. 45
    www.ErnestChiang.com

    View full-size slide

  46. © 2022, Amazon Web Services, Inc. or its affiliates. 46
    www.ErnestChiang.com

    View full-size slide

  47. © 2022, Amazon Web Services, Inc. or its affiliates. 47
    www.ErnestChiang.com

    View full-size slide

  48. © 2022, Amazon Web Services, Inc. or its affiliates. 48
    www.ErnestChiang.com

    View full-size slide

  49. © 2022, Amazon Web Services, Inc. or its affiliates. 49
    www.ErnestChiang.com

    View full-size slide

  50. © 2022, Amazon Web Services, Inc. or its affiliates. 50
    > php artisan migrate
    www.ErnestChiang.com

    View full-size slide

  51. © 2022, Amazon Web Services, Inc. or its affiliates. 51
    www.ErnestChiang.com

    View full-size slide

  52. © 2022, Amazon Web Services, Inc. or its affiliates. 52
    www.ErnestChiang.com

    View full-size slide

  53. © 2022, Amazon Web Services, Inc. or its affiliates. 53
    www.ErnestChiang.com

    View full-size slide

  54. © 2022, Amazon Web Services, Inc. or its affiliates. 54
    www.ErnestChiang.com

    View full-size slide

  55. © 2022, Amazon Web Services, Inc. or its affiliates. 55
    www.ErnestChiang.com

    View full-size slide

  56. © 2022, Amazon Web Services, Inc. or its affiliates. 56
    www.ErnestChiang.com

    View full-size slide

  57. © 2022, Amazon Web Services, Inc. or its affiliates. 57
    www.ErnestChiang.com

    View full-size slide

  58. © 2022, Amazon Web Services, Inc. or its affiliates. 58
    www.ErnestChiang.com

    View full-size slide

  59. © 2022, Amazon Web Services, Inc. or its affiliates. 59
    www.ErnestChiang.com

    View full-size slide

  60. © 2022, Amazon Web Services, Inc. or its affiliates. 60
    www.ErnestChiang.com

    View full-size slide

  61. © 2022, Amazon Web Services, Inc. or its affiliates. 61
    www.ErnestChiang.com

    View full-size slide

  62. img src: https://unsplash.com/photos/aEnH4hJ_Mrs
    /,ɔrkʌs`treɪʃʌn/ arrangement
    Orchestration
    www.ErnestChiang.com

    View full-size slide

  63. © 2022, Amazon Web Services, Inc. or its affiliates. 63

    View full-size slide

  64. © 2022, Amazon Web Services, Inc. or its affiliates. 64
    www.ErnestChiang.com

    View full-size slide

  65. © 2022, Amazon Web Services, Inc. or its affiliates. 65
    www.ErnestChiang.com

    View full-size slide

  66. © 2022, Amazon Web Services, Inc. or its affiliates. 66
    2
    1
    1 2

    View full-size slide

  67. © 2022, Amazon Web Services, Inc. or its affiliates. 67
    www.ErnestChiang.com

    View full-size slide

  68. © 2022, Amazon Web Services, Inc. or its affiliates. 68
    2
    1
    1 2

    View full-size slide

  69. © 2022, Amazon Web Services, Inc. or its affiliates. 69

    View full-size slide

  70. © 2022, Amazon Web Services, Inc. or its affiliates. 70
    1 2
    www.ErnestChiang.com

    View full-size slide

  71. img src: Photo by sergio souza on Unsplash
    orchestration
    Amazon ECS
    www.ErnestChiang.com

    View full-size slide

  72. © 2022, Amazon Web Services, Inc. or its affiliates. 72
    www.ErnestChiang.com

    View full-size slide

  73. © 2022, Amazon Web Services, Inc. or its affiliates. 73
    1 2

    View full-size slide

  74. © 2022, Amazon Web Services, Inc. or its affiliates. 74
    1 2
    1 2

    View full-size slide

  75. © 2022, Amazon Web Services, Inc. or its affiliates. 75

    View full-size slide

  76. © 2022, Amazon Web Services, Inc. or its affiliates. 76
    www.ErnestChiang.com

    View full-size slide

  77. © 2022, Amazon Web Services, Inc. or its affiliates. 77
    www.ErnestChiang.com

    View full-size slide

  78. © 2022, Amazon Web Services, Inc. or its affiliates. 78
    www.ErnestChiang.com

    View full-size slide

  79. © 2022, Amazon Web Services, Inc. or its affiliates. 79
    www.ErnestChiang.com

    View full-size slide

  80. © 2022, Amazon Web Services, Inc. or its affiliates. 80
    www.ErnestChiang.com

    View full-size slide

  81. © 2022, Amazon Web Services, Inc. or its affiliates. 81
    www.ErnestChiang.com

    View full-size slide

  82. © 2022, Amazon Web Services, Inc. or its affiliates. 82

    View full-size slide

  83. © 2022, Amazon Web Services, Inc. or its affiliates. 83
    www.ErnestChiang.com
    AWS Fargate
    Amazon EC2

    View full-size slide

  84. © 2022, Amazon Web Services, Inc. or its affiliates. 84
    www.ErnestChiang.com
    AWS Fargate
    Amazon EC2

    View full-size slide

  85. img src: Photo by sergio souza on Unsplash
    on Amazon ECS
    Running Laravel
    www.ErnestChiang.com

    View full-size slide

  86. © 2022, Amazon Web Services, Inc. or its affiliates. 86
    www.ErnestChiang.com
    AWS Fargate
    Fargate LT

    View full-size slide

  87. © 2022, Amazon Web Services, Inc. or its affiliates. 87
    www.ErnestChiang.com
    AWS Fargate
    Fargate LT

    View full-size slide

  88. © 2022, Amazon Web Services, Inc. or its affiliates. 88
    www.ErnestChiang.com
    AWS Fargate
    Fargate LT

    View full-size slide

  89. © 2022, Amazon Web Services, Inc. or its affiliates. 89

    View full-size slide

  90. © 2022, Amazon Web Services, Inc. or its affiliates. 90
    www.ErnestChiang.com
    ECR
    AWS Fargate
    Fargate LT

    View full-size slide

  91. © 2022, Amazon Web Services, Inc. or its affiliates. 91
    S. (I) V. O. (image)
    ECR
    www.ErnestChiang.com
    AWS Fargate
    Fargate LT

    View full-size slide

  92. © 2022, Amazon Web Services, Inc. or its affiliates. 92
    S. (ECS)
    V.
    O.
    ECR
    www.ErnestChiang.com
    AWS Fargate
    Fargate LT

    View full-size slide

  93. © 2022, Amazon Web Services, Inc. or its affiliates. 93
    S. (CI)
    V.
    O.
    CI
    www.ErnestChiang.com
    AWS Fargate
    Fargate LT

    View full-size slide

  94. © 2022, Amazon Web Services, Inc. or its affiliates. 94
    www.ErnestChiang.com

    View full-size slide

  95. © 2022, Amazon Web Services, Inc. or its affiliates. 95
    www.ErnestChiang.com Search "ernest laravel ecs workshop" to download.

    View full-size slide

  96. © 2022, Amazon Web Services, Inc. or its affiliates. 96
    www.ErnestChiang.com Search "ernest laravel ecs workshop" to download.
    Amazon ECR

    View full-size slide

  97. Demo
    www.ErnestChiang.com
    never live demo!

    View full-size slide

  98. © 2022, Amazon Web Services, Inc. or its affiliates.
    Laravel 8.49.1


    with


    PHP 7.4.21


    on


    Different Docker Base Images
    98

    View full-size slide

  99. © 2022, Amazon Web Services, Inc. or its affiliates. 99
    www.ErnestChiang.com

    View full-size slide

  100. © 2022, Amazon Web Services, Inc. or its affiliates. 100
    www.ErnestChiang.com

    View full-size slide

  101. © 2022, Amazon Web Services, Inc. or its affiliates. 101
    www.ErnestChiang.com

    View full-size slide

  102. © 2022, Amazon Web Services, Inc. or its affiliates.
    Laravel 8.19.0


    with


    PHP 8.0/7.4/7.3


    on


    Buster/Alpine 3.12
    102

    View full-size slide

  103. © 2022, Amazon Web Services, Inc. or its affiliates. 103
    www.ErnestChiang.com

    View full-size slide

  104. © 2022, Amazon Web Services, Inc. or its affiliates. 104
    www.ErnestChiang.com

    View full-size slide

  105. © 2022, Amazon Web Services, Inc. or its affiliates. 105
    www.ErnestChiang.com

    View full-size slide

  106. 參考資料
    www.ErnestChiang.com
    Reference

    View full-size slide

  107. © 2022, Amazon Web Services, Inc. or its affiliates.
    參考資料
    Virtualization
    • Wikipedia - Virtualization

    • https://en.wikipedia.org/wiki/Virtualization

    • Playing With Firecracker VMM at COSCUP 2020

    • https://www.ernestchiang.com/en/posts/2020/playing-with-
    fi
    recracker/

    • Firecracker

    • https://
    fi
    recracker-microvm.github.io/
    107

    View full-size slide

  108. © 2022, Amazon Web Services, Inc. or its affiliates.
    參考資料
    Virtualization
    • Linux 核⼼設計_發展動態回顧

    • https://www.youtube.com/watch?v=-2Pn4B8S1EM

    • Embedded Virtualization applied in Mobile Devices

    • https://www.slideshare.net/jserv/mobile-virtualization
    108

    View full-size slide

  109. © 2022, Amazon Web Services, Inc. or its affiliates.
    參考資料
    Containerization
    • Wikipedia - OS-level virtualization

    • https://en.wikipedia.org/wiki/OS-level_virtualization
    109

    View full-size slide

  110. © 2022, Amazon Web Services, Inc. or its affiliates.
    參考資料
    Docker / Laravel / PHP
    • Docker image of nginx + php-fpm (amd64/arm64)

    • https://hub.docker.com/r/dwchiang/nginx-php-fpm

    • Open source (Apache-2.0 license)

    • https://github.com/dwchiang/nginx-php-fpm

    • 50 Stars / 17 Forks
    110

    View full-size slide

  111. © 2022, Amazon Web Services, Inc. or its affiliates.
    參考資料
    Amazon ECS
    • Ernest's Study Notes on ECS

    • https://www.ernestchiang.com/en/notes/aws/ecs/

    • Nathan Peck's Awesome List

    • https://github.com/nathanpeck/awesome-ecs

    • 技術選型: Amazon ECS Launch Types: EC2 vs. Fargate

    • https://www.ernestchiang.com/zh/posts/2020/technology-selection-amazon-ecs-launch-
    type/

    • 5 Steps: Using Amazon ECS Exec to pass through Fargate/ECS into containers

    • https://www.ernestchiang.com/en/posts/2021/using-amazon-ecs-exec/
    111

    View full-size slide

  112. © 2022, Amazon Web Services, Inc. or its affiliates.
    參考資料
    Running Laravel on Amazon ECS
    • Workshops: Running Laravel on AWS ECS (using CDK)

    • https://github.com/dwchiang/laravel-on-aws-ecs-workshops

    • CDK Construct Hub

    • https://constructs.dev/

    • CDK patterns for modern application with serverless containers on AWS

    • https://github.com/aws-samples/serverless-container-constructs

    • My study notes on CDK

    • https://www.ernestchiang.com/en/notes/aws/cdk/
    112

    View full-size slide

  113. © 2022, Amazon Web Services, Inc. or its affiliates. 113
    Search "ernest aws ecs" to download.

    View full-size slide

  114. © 2022, Amazon Web Services, Inc. or its affiliates.
    Ernest's Blog
    • https://www.ernestchiang.com
    拆解整合的旅⼈
    114

    View full-size slide

  115. 問與答
    www.ErnestChiang.com
    更多對話

    View full-size slide

  116. UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
    © 2022, Amazon Web Services, Inc. or its affiliates.
    Thank you!
    © 2022, Amazon Web Services, Inc. or its affiliates.
    Ernest Chiang
    Twitter @dwchiang
    AWSUG TW
    https://www.facebook.com/
    groups/awsugtw

    View full-size slide