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

2f42f32689c8244280dd01d864f92079?s=128

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
  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
  3. © 2022, Amazon Web Services, Inc. or its affiliates. 拆.解.整.合.的.旅.⼈

    • PAFERS
 Product & Technology Integration • AWS
 Community Hero • ex-TSMC
 Process Integration Engineer Ernest Chiang 3
  4. PAFERS We Build Connected Fitness

  5. PAFERS Bluetooth Classic Fitness Consoles

  6. Bluetooth Event Europe

  7. PAFERS Contributes Industry Knowledge to Bluetooth Spec https://www.bluetooth.com/specifications/gatt/

  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)
  9. Global PAFERS Edges Footprints

  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
  11. img src: https://commons.wikimedia.org/wiki/File:Cair_Pavarel.jpg Laravel/PHP www.ErnestChiang.com issues?

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

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

    本機 開始 13
  14. © 2022, Amazon Web Services, Inc. or its affiliates. 先⼿動,再⾃動。

    14
  15. © 2022, Amazon Web Services, Inc. or its affiliates. 我

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

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

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

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

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

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

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

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

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

    24
  25. © 2022, Amazon Web Services, Inc. or its affiliates. 25

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

    www.ErnestChiang.com
  27. © 2022, Amazon Web Services, Inc. or its affiliates. 所以?將

    PHP Code 打包? 27
  28. © 2022, Amazon Web Services, Inc. or its affiliates. 還是

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

    外加 作業系統 ⼀起打包? 29
  30. © 2022, Amazon Web Services, Inc. or its affiliates. 好,⾄少我們知道這台電腦不能打包。

    30
  31. solution? Virtualization www.ErnestChiang.com

  32. © 2022, Amazon Web Services, Inc. or its affiliates. Creating

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

    a virtual version of something; 33
  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
  35. © 2022, Amazon Web Services, Inc. or its affiliates. 35

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

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

  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
  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
  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
  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
  42. © 2022, Amazon Web Services, Inc. or its affiliates. 42

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    www.ErnestChiang.com AWS Fargate Amazon EC2
  85. img src: Photo by sergio souza on Unsplash on Amazon

    ECS Running Laravel www.ErnestChiang.com
  86. © 2022, Amazon Web Services, Inc. or its affiliates. 86

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

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

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

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

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

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

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

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

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

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

    www.ErnestChiang.com Search "ernest laravel ecs workshop" to download. Amazon ECR
  97. Demo www.ErnestChiang.com never live demo!

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

    8.49.1 with PHP 7.4.21 on Different Docker Base Images 98
  99. © 2022, Amazon Web Services, Inc. or its affiliates. 99

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

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

    www.ErnestChiang.com
  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
  103. © 2022, Amazon Web Services, Inc. or its affiliates. 103

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

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

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

  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
  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
  109. © 2022, Amazon Web Services, Inc. or its affiliates. 參考資料

    Containerization • Wikipedia - OS-level virtualization • https://en.wikipedia.org/wiki/OS-level_virtualization 109
  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
  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
  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
  113. © 2022, Amazon Web Services, Inc. or its affiliates. 113

    Search "ernest aws ecs" to download.
  114. © 2022, Amazon Web Services, Inc. or its affiliates. Ernest's

    Blog • https://www.ernestchiang.com 拆解整合的旅⼈ 114
  115. 問與答 www.ErnestChiang.com 更多對話

  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