How to Host Your PHP Web App in AWS
AWS offers many options for hosting a PHP website through their services & partner ecosystem. EC2 + Beanstalk are services for traditional websites. App Runner, ECS & Kubernets are great for container & cloud-native PHP applications. AWS also offers an entire partner ecosystem to make hosting easy.
AWS PHP Web Application Hosting Options
Hosting Option | Ease of Setup | Scalability | Cost | Deployment | Customization |
---|---|---|---|---|---|
Elastic Beanstalk | Easy | High | Medium | Easy | Medium |
Lightsail | Easy | Medium | Low | Medium | Low |
Amplify | Easy | High | Medium | Medium | Medium |
App Runner | Easy | High | Medium | Easy | Medium |
EC2 | Medium | High | Low | Medium | High |
ECS / ECR | Medium-Hard | High | Medium | Medium | High |
Lambda | Medium-Hard | High | Low | Medium | High |
EKS | Hard | High | Medium-High | Hard | High |
AWS PHP App Hosting Highlights
- Traditional server-hosted app: Use an EC2 instance to host & manage a website using traditional server-style hosting in the AWS cloud.
- Container-provided app: AWS provides several services such as ECS, Kubernetes, Lambda, App Runner, and more that encourage container-based deployment.
- Automated & managed services: The partner ecosystem has hundreds of managed & productized service providers to help you set up, manage & deploy your website into AWS.
Table of Contents
- Hosting Websites in AWS Cloud
- Traditional Server Hosted PHP Website
- AWS Cloud-Native PHP Container Hosting
- AWS Serverless PHP Hosting

Maximize the Value You Get AWS for Your Applications

Stop running in circles and develop your applications faster and cheaper in AWS. This guide will walk you through ways to maximize AWS to generate real value for your needs. We dive into picking the right services to scale, tighten security and maximize costs.
Download our free guide now and get started with confidence.
Is AWS Good for PHP Website Hosting
AWS is an excellent choice to host your website in the cloud when you run a high-traffic, dynamic, and enterprise application. It is wise to use the service whenever you plan to use additional AWS service. On the other hand, AWS is too expensive & complex for smaller, less resource-intensive websites.
Pros & Cons of Hosting Web Apps in AWS
Pros
- High-Availability
- Unlimited Scale
- Total amount of available services
- Large AWS partner ecosystem
- Cost control at scale
- Emphasis on security
- Total control of environment
Cons
- Extreme complexity for simple requirements
- Large learning curve
- Costs can quickly balloon with experience
- Simpler options for smaller sites
When You Should Use AWS to Host Your PHP Application
AWS is an excellent cloud service for when you need it. It is common to use it for high-traffic websites or PHP applications that require complexity. I will avoid it if you are trying it out because you’ve heard about it and don’t have a strong partner to help manage it.
Use AWS for Web Hosting:
- High-traffic websites
- Complex Web Applications
- Experience in the environment
- Using other AWS services
- Have a managed service partner
Avoid AWS for Web Hosting:
- Small-traffic websites
- Simple & Stable application
- Lack of experience or exposure
- Doing it just because
- Not utilizing a partner
Web Apps Cloud Hosting Options
AWS is one of many options to host your PHP web application in the Cloud. GCP & Azure are the other 2 major cloud providers, but you aren’t limited to these 3 providers. Digital Ocean is a popular option for startups and developer-led organizations as that is their primary target audience.
Click here to read our in-depth guide on Cloud Web Hosting
We recommend 4 options to host your PHP Application in AWS. You can set up an EC2 instance yourself, use Elastic Beanstalk, use AWS Fargate, or choose the new App Runner Service
This article explores options to host a PHP application in the cloud with AWS. It features three options for hosting a PHP website on AWS, including EC2, Elastic Beanstalk, and Fargate. This article is an overview, and it doesn’t walk you through deploying applications – that’s something we will tackle in the upcoming articles.
This article is one of our foundational articles for developing PHP applications in AWS. Building & Deploying on AWS has its unique benefits and challenges.
Host & deploy a traditional PHP web application on AWS EC2
EC2 instances are Amazon’s service to help serve web applications via a standard bare-metal server. You can host, manage & deploy your applications onto an EC2 like any other webserver. SSH to setup cron jobs, setup git deploys, and more. EC2 is your private server space in the AWS environment.
Amazon Elastic Cloud Compute (EC2) is a virtual computing capacity in the cloud that is secure and scalable. Amazon offers immense leverage to choose the computing resource type, the operating system, and a configurable firewall (aka security groups). On top of that, Amazon’s Identity and Access Management (IAM) provides a layer of security and takes care of authentication and authorization so that your EC2 instances are always in safe hands.

You can also choose the pricing model that best suits you – On-demand, Spot, Dedicated, and Shared instances. There is also a free tier available.

Using EC2 for hosting a PHP website on AWS means you have the compute resource. It is your job to configure it, install the necessary packages, upload your application’s source code, and finally spin up the server. Besides, you will require to create a database and object storage too.
Although AWS provides and maintains all the resources, it leaves you some configuration and setup tasks. Depending on a case-to-case basis, having a clean slate may be ideal, but some developers would need an abstraction.
And that’s why we jump to the next section, where we see how Elastic Beanstalk goes further to make our deployment more effortless.
Pros
- Complete freedom over your infrastructure.
- Choose a platform of your choice.
- Fine-grain control over network and security.
- More flexibility and scalability.
Cons
- operational overhead & server administration is involved.
- Requires more expertise and experience.
- Time-consuming to build the infrastructure.
When to host a PHP application in AWS using a standard EC2 deploy?
Recommended If
- You want the freedom to control the lowermost infrastructure configurations.
- You have SysOps and CloudOps experience and expertise.
- You want to test your MVP and need minimal setup for that.
- You want a highly flexible and scalable solution.
Not Recommended If
- You want to minimalize operational overhead.
- You lack experience and expertise in cloud computing.
- You have a smaller team that lacks server management experience.
Managing Your Website on an AWS EC2 Instance
EC2 instances are great. They are powerful, flexible, affordable and scalable. But who wants to setup, manage, & upgrade a server? This is where the AWS ecosystem & partner program is available for you. AWS provides several in-house services to help you manage your website on AWS. In addition, they have a large partner network of various levels of support.
Types of Services to Manage Your EC2 Hosted Application
- AWS provided managed services
- AWS solution provider partners
- AWS platform managed service provider
AWS Provided Services to Manage Your PHP Website on an EC2 Instance
Elastic Beanstalk:
Let AWS help provision, manage & autoscale your EC2 instances with preconfigured setup.
What it does
- Quickly provision preconfigured EC2 instances to match your requirements
- Apply autoscaling rules
- Manage Linux server upgrades
- Simple app deployment options
- Configuration to pre-install software when provisioning
Host a PHP Application in AWS with Elastic Beanstalk
AWS Elastic Beanstalk is a platform-as-a-service, and contrary to infrastructure-as-a-service, it is more than just a compute resource in the cloud. It is a managed service that makes your deployments easier. You only need to upload your source code, and Beanstalk handles the rest.
Related Articles on AWS Beanstalk
Want to dig deeper into Beanstalk? Check out the following articles to dive further into Beanstalk for more in-depth analysis.
- App Runner vs Beanstalk for Application Hosting
- AWS Lightsail vs Elastic Beanstalk
- Azure App Service vs Elastic Beanstalk
- Elastic Container Service (ECS) vs Elastic Beanstalk
- Deploy Laravel from Github to Elastic Beanstalk via CodePipeline
- Deploy Laravel to Elastic Beanstalk using GitHub Actions
- Host & Deploy a Laravel App to AWS Elastic Beanstalk

It automates the server configuration, scaling, and load balancing task, which is your responsibility if you go with the former approach of using EC2 instances. There’s no additional cost to Beanstalk; you only pay for the underlying resources.
Beanstalk supports famous languages and frameworks – PHP, Java, Node.js, Ruby, Python, .NET, Go, and Docker. You can deploy these on well-known servers like Nginx, Apache, Passenger, and IIS.

Another important takeaway is that it allows you to choose the type of resources and software before creating the deployment. It lets you monitor application health based on 40+ metrics and uses efficient monitoring and logging solutions.
So long story short, if you want to get over operational overhead and speed up deployments, Elastic Beanstalk is the way to go.
Pros
- Easy-to-use service for deploying applications.
- Requires less expertise and experience.
- Easily integrate with CI/CD pipelines.
- Time and cost-efficient.
- It gives you the freedom to choose underlying resources.
Cons
- Less control over the custom infrastructure.
- Integrating third-party services can be daunting.
- Orchestrating multiple applications can be challenging.
- Custom configurations and complex extension files can affect its performance.
When to host a PHP application in AWS using Elastic Beanstalk?
Recommended If
- You want effortless deployment without having to worry about operational overhead.
- You don’t want to spend on IT and Cloud training and onboarding.
- You have a relatively simple application: a blog site, an API, or a front-end application.
Not Recommended If
- If your application uses complex task and messaging queues.
- Your application relies heavily on third-party integrations.
- You have microservices or distributed applications.
Deploy PHP Apps into AWS Elastic Beanstalk
Interested in reading more about AWS Elastic Beanstalk for your PHP app? We’ve written additional articles specific to managing, hosting & deploying PHP Apps into Beanstalk. Click on the following links to dig deeper into maximizing Beanstalk for your application.
- How to host and deploy a Laravel app into AWS Beanstalk
- Deploy Laravel App Using CI/CD with Github Actions
How to Host Your PHP Containers in AWS
AWS offers several services for hosting PHP containers: Amazon Elastic Container Service (ECS), Amazon Elastic Kubernetes Service (EKS), App Runner, Lambda, and Beanstalk. ECS & EKS are traditional cloud-native services and App Runner uses ECS under the hood.
- AWS offers several options for hosting containers.
- Amazon Elastic Container Service (ECS) and Elastic Kubernetes Service (EKS) are the most popular and traditional cloud-native services.
- With ECS, you can easily run and manage Docker containers in a fully managed environment.
- With EKS, you can deploy and manage containers with Kubernetes, while AWS manages the underlying infrastructure.
- App Runner is a new service that makes building, deploying, and scaling containerized applications easy.
- With App Runner, you define your application and dependencies using CDK code, and App Runner handles the deployment and scaling for you.
Deploy Your PHP App Container into AWS with the New App Runner Service
AWS recently launched a new service to deploy web apps that compete directly with Heroku called App Runner. I am really enjoying this service as I’ve used and recommended it for several projects. It is a great solution for many startups and proofs of concept. Most larger organizations will want to switch to ECS as they grow but this is a great service for any web developer who do not want to manager infrastructure.
Related App Runner Articles
Dig deeper into AWS App Runner. Check out our other articles where we dig deep into the AWS app hosting service.
- AWS App Runner vs. Azure App Service
- AWS App Runner vs. GCP Cloud Run
- Using AWS App Runner vs Elastic Beanstalk
- App Runner vs Heroku
- AWS App Runner vs Fargate
- What is AWS App Runner
Host a Serverless PHP App in AWS
AWS offers several serverless services to host your PHP App: Fargate & Lambda. You can deploy PHP apps into Fargate with a custom runtime or docker container. Fargate makes cloud-native container management easy for your PHP applications.
PHP Serverless Hosting Key Points
- You can use Lambda and Fargate to host your PHP applications
- Lambda is a good option when you have small event-driven requirements
- Fargate sits on Elastic Container Service and is ideal for high scale requirements
Run PHP in Lambda
AWS Lambda is a serverless computing service that lets you run code without provisioning or managing servers. With Lambdas, you can easily run your PHP applications and only pay for the computing time you consume.
You wouldn’t be alone if you didn’t know that you could host PHP applications in Lambda.
Most people aren’t aware that you can deploy PHP into Lambda. They generally think of Lambda as a service for Javascript, Go, Python or another similar language. But you can and sometimes should use the powerful Lambda service for hosting your PHP code.
We’ve written an in-depth guide to use PHP inside of AWS Lambda. Click here to check it out.
Pros:
- No infrastructure management required
- Only pay for the compute time you consume
- High scalability and availability
Cons:
- Limited customization options
- Cold starts can result in slow performance for some applications
Host a Docker Container PHP Application in AWS Fargate
AWS Fargate is a serverless computing service that lets you upload dockerized PHP applications using Amazon Elastic Container Service (ECS) and Amazon Elastic Kubernetes Service (EKS). Container and container orchestration is yet another complex topic, but we will tackle it in future articles. This approach is helpful if you want to deploy multiple applications, such as microservices.

Another buzzword is serverless, and the name speaks for itself. You don’t have to worry about provisioning, monitoring, and scaling your servers, but all you need is to deploy the containers on Fargate; the rest is not your headache.

Pros
- Serverless architecture.
- Creates infrastructure using docker templates.
- Easy to deploy and migrate.
- Ideal for multiple and distributed applications.
Cons
- Must have a containerized app
- Shouldn’t use standard PHP sessions in containers
- Knowledge of serverless and containers are expected
When to host a PHP application in AWS using Fargate?
Recommended If
- You have distributed applications with orchestration requirements.
- You have experience and expertise in Serverless, cloud-native and similar technologies.
- You want serverless architecture for your application.
Not Recommended If
- You’re an early-stage startup trying to validate your product.
- You want fine-grained control over the infrastructure resources.
- Legacy systems with heavy usage of PHP sessions
- Legacy apps that aren’t containerized
Host a PHP Application in AWS using Platform-as-a-Service
There are a bunch of platform-as-a-service options available that help you deploy effortlessly. They use the computing resources of the popular platforms but provide a layer of abstraction. With PaaS, you don’t have to worry about server configuration, monitoring, management, and scaling because they are already managed for you – much similar to Elastic Beanstalk.
To name a few – Cloudways, Heroku, Laravel Forge.
We have already seen the upsides, downsides, and use cases for Elastic Beanstalk, which is PaaS, so consider reading that.
But What is the Cloud?
Cloud hosting is all about virtually using a third party’s computing resources. You don’t have to worry about procuring and managing those resources. These third-party vendors provide Infrastructure-as-Service (IaaS), meaning you can use their resources on-demand and pay as you go.
Think of it as renting a resource without worrying about physically placing it in your space and doing all the hard stuff yourself, like adding up more storage or processors or setting up complicated software like operating systems and firewalls from scratch.
So, it takes care of infrastructure management, saving you time and money. The following section overviews the advantages of the cloud.
The Top Three Cloud Providers
The Cloud computing industry is hot these days as many companies and startups are migrating to the cloud, but the top three that stand out are
- Amazon Web Services (AWS)
- Microsoft Azure
- Google Cloud
As the following bar chart suggests, the list is not sorted randomly but in order of the market shares by Q4 of 2021.

As the bar chart shows, there are other cloud platforms besides the major players, but we will be focus on AWS. However, you can do your research and pick the one that best suits your needs. We chose AWS because of the trust factor and reliability since it is the oldest cloud provider and has already accumulated a huge customer base.
Cost is one of the primary concerns, and you should always be aware of the costs. AWS is expensive but definitely worth it – not advertising it but sharing experience as a customer using it for a long time now.
Alternatives to Cloud
There’s a spectrum of hosting options where shared hosting falls on one extreme and dedicated hosting falls on the other. In the middle, we see VPS and Cloud. I love the analogies made in the image below.

VPS could be an alternative, but many factors must be considered before choosing either. So what is VPS, and what are the best use cases?
Using Virtual Private Server (VPS) to Host PHP Applications
A Virtual Private Server (VPS) is a server instance, like AWS EC2. VPS providers use virtualization software that logically divides one physical server into different logical server instances that customers can purchase. You apparently get dedicated resources, which opens doors for high customization and control of the computing resources.
Some well-known VPS providers are Hostinger, GoDaddy, BlueHost, A2 Hosting, InMotion, HostGator, and many others, infact.
Recommended If
- You want to have fine-grained control like an on-premise physical server.
- You have expertise in IT and DevOps.
- You have steady bandwidth requirements.
- You can find cost-effective plans
Not Recommended If
- You have customer-centric or time-critical applications.
- You want immense scalability and uptimes.
- Your application has heavy network traffic.
- You have experience and expertise in cloud computing.
Is AWS Cheaper than Shared Hosting
Generally, no. Shared hosting will almost always be cheaper than AWS hosting a simple PHP website. This is because you are using the same server as other organizations with shared hosting. This is not the case for AWS resources.
Shared hosting is an excellent service for small & beginner websites. You can pool the same resources as other orgs that are in the same size & requirements as you. But, it quickly loses strength as your app requirements grow.
You will get slower performance on shared hosting when you get significant traffic to your PHP website. I also wouldn’t recommend shared hosting for any web application as you will be very limited in what you can develop and deploy. You may get it to work for a proof of concept or testing, but there are better options if you work on more than a WordPress website.
Benefits of AWS Hosting
Speed and Scalability
Speed is crucial, especially for startups that must take their MVP to the market before the competition. If you wait for weeks and months just to set up the initial infrastructure and then spend another few weeks scaling it up, you may need to re-evaluate your strategy.
Setting up everything you need and making your product go live takes minutes. Besides that, AWS platforms use intelligent software to scale your computing resources and meet the changing demands without affecting up-times.
Efficiency
Time and tide wait for none, but you can turn the odds in your favor using your money and time efficiently. AWS let you purchase resources on-demand with an opportunity to scale anytime. So, you need not invest heavily in the early stages and scale up as efficiently as possible.
Besides, cloud platforms look after the IT and security-related complexities for you, so you don’t have to worry about it nor have to spend on hiring IT and security resources to look after the on-premise resources otherwise.
Safety & Recovery
Cloud vendors like AWS, Microsoft Azure, Google, and other popular platforms have data centers across the regions, so you’re not confined to a single server or data center. So, providing backups and substitutes is yet another win for AWS. Consequently, your infrastructure and data are always immune to any mishap.
Focus on your Product
AWS takes away much of the hard work of scaling & managing servers. It lets you focus on your business, marketing website, product & customer experience.
With all these aspects taken care of, you can focus entirely on your business.
AWS vs On-Premise – Who’s the Winner?
On-premise hosting is when you deploy your organization’s infrastructure in-house. Though after all the benefits of AWS, this may sound odd as to why an organization would opt for in-house. Some businesses in highly regulated industries where data privacy is critical may consider on-premise—for instance – government agencies and educational institutes.
For businesses and startups, I think on-premise is overkill. That’s why some really popular startups and enterprises use cloud solutions – Examples are Airbnb, Uber, Reddit, Heroku, and many others – check out Amazon’s startup wall.

Host Web Apps in AWS
AWS provides many different web hosting options in its ecosystem.
You can use their services directly or as a managed provider through partner programs. The application can deploy directly into a traditional EC2 instance or cloud-native in a Kubernetes cluster.
We enjoy using & deploying PHP web applications into the AWS environment. There are many benefits to using this cloud provider because of its market dominance. On the other hand, it can be fairly complicated to get onboarded and work in the ecosystem. I recommend finding an experienced partner or AWS architect to help you understand the landscape.
I’d also like to point out that AWS isn’t the only PHP cloud hosting option. Azure, GCP, & Digital Ocean are also really great options. We’ve written a very in-depth guide to help you navigate your cloud options.
Click here to read our PHP Cloud Hosting Guide
Cloud Hosting Article Series
This article is part of our series on cloud hosting for your web applications. Check out the following articles to dig further into your options.
- Best Cloud PHP Hosting Providers for Apps Compared
- Hosting PHP Website Apps in AWS Cloud
- Hosting PHP Web Apps in Azure Cloud
- Hosting PHP Web Apps in Google Cloud
- What is AWS App Runner
- PHP in AWS Lambda
- App Runner vs. Elastic Beanstalk
- App Runner vs Google Cloud Run
- AWS App Runner vs. Azure App Service
- Azure App Service vs Elastic Beanstalk
- Azure App Service vs Google Cloud Run
- Google Cloud Run vs Heroku
- Host & Deploy a Laravel App to AWS Elastic Beanstalk
Hosting Web Applications in AWS
This article is part of our series to make AWS easy. We love AWS, but let’s be honest. It isn’t effortless. Like way too complicated. We’ve created this learning path to help level you up and get your PHP app onboarded fast.
- Is AWS Cloud Services Hard to Learn?
- AWS PHP Website & Application Hosting Options
- Using PHP in AWS Lambda: Comparing Options
- Deploy Laravel to Elastic Beanstalk using GitHub Actions
- Deploy Laravel from Github to Elastic Beanstalk via CodePipeline
- Install LAMP Stack on AWS EC2
- Install AWS SDK for PHP
- Host and Deploy a Laravel PHP App to AWS Elastic Beanstalk
- Amplify vs Elastic Beanstalk
- AWS App Runner Review
- App Runner vs Elastic Beanstalk
- App Runner vs Fargate
- Elastic Beanstalk vs AWS Lightsail
- Elastic Container Service vs Beanstalk
- Setup & Use AWS Parameter Store in PHP
- How to use AWS Secrets Manager with PHP
- PHP & AWS S3
Maximize the Value You Get AWS for Your Applications

Stop running in circles and develop your applications faster and cheaper in AWS. This guide will walk you through ways to maximize AWS to generate real value for your needs. We dive into picking the right services to scale, tighten security and maximize costs.
Download our free guide now and get started with confidence.