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
  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 Fitness Services (PFS) The integrated products and services for

    fitness. Smart 
 Fitness 
 Consoles Video 
 Streaming Services Gym Management Services 
 (GMS) Training Content 
 Services 
 (TCS)
  5. © 2022, Amazon Web Services, Inc. or its affiliates. Outline

    ⼤綱 • Laravel/PHP • Virtualization 👉 Containerization 👉 Orchestration • Amazon ECS • Laravel on Amazon ECS • Reference • Q & A 10
  6. © 2022, Amazon Web Services, Inc. or its affiliates. 12

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

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

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

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

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

    外加 作業系統 ⼀起打包? 29
  12. © 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
  13. © 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
  14. © 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
  15. © 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
  16. © 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
  17. © 2022, Amazon Web Services, Inc. or its affiliates. 50

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

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

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

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

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

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

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

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

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

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

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

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

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

    8.49.1 with PHP 7.4.21 on Different Docker Base Images 98
  31. © 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
  32. © 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
  33. © 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
  34. © 2022, Amazon Web Services, Inc. or its affiliates. 參考資料

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

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

    Blog • https://www.ernestchiang.com 拆解整合的旅⼈ 114
  40. 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