In this detailed article on hosting websites on AWS, we will learn how to host a website on AWS, discover the different AWS hosting plans, learn about the AWS web hosting pricing, and discuss a few related topics such as the following:
- What is AWS Hosting?
- How to host a website on AWS S3?
- What are the steps for hosting a website on AWS EC2?
- What is the cost of hosting a dynamic website on AWS?
- AWS Web Hosting Pricing Plans
- How to host a website on AWS Lambda?
What Is AWS Hosting?
Amazon Web Services (AWS) is a public cloud platform that offers a lot of services like computing, ML, also cloud web hosting services to businesses, individuals, and governments at inexpensive prices. It is a public cloud that allows others to rent a share of massive server farms and data centers.
AWS offers website hosting services, application hosting services, file hosting services, and database hosting services, in addition to other types of hosting. It is one of the biggest cloud infrastructures, with notable companies like Netflix using its services.
AWS made up about 32% of global cloud infrastructure in the first quarter of 2021. It offers a diverse mix of over 200 different services.
hosting websites on AWS s3 – Step by step
If you are a beginner with no prior knowledge or experience with AWS, then here you will know How To Host A Website On AWS S3? First, you will have to create an AWS Account, Don’t worry it is free and you don’t have to pay anything upfront. You can use the free tier that will cover most of the things for a beginner.
Follow along and we will be hosting a website together in AWS:
1. Signing Up on AWS
Create an AWS account here. It’s free.
2. Hosted Zone Creation With Route 53
Now the first thing that you would want to do is to set up a hosted zone on Route 53. It is where your DNS requests will be taken care of. This step is going to be very easy if you purchase the domain through AWS because once you purchase the domain, a hosted zone will be created.
But if you did not purchase your domain through AWS, go to Route 53 and select the “Create Hosted Zone” option. Now fill in all the details, select a “Public Hosted Zone,” and hit the “Create” option.
You will now need your Name Servers records. For that, log in to your domain name registrar and find the settings for “Nameservers,” which is an editable section. Now copy down the AWS NS records and change the current Name Servers records in the domain settings.
Make sure you don’t copy the period at the end of the “.com.”. It should be like this “.com” The process will take 24 hours to sync. Go ahead and set up your S3 buckets in the meantime.
3. Setting Up the S3 Buckets
S3 buckets are an S3 resource where you store your data, such as your index.html files. You will need to set up two S3 buckets for your website: one for yourdomain.com and one for www.yourdomain.com.
In the first bucket, you will store all your documents, including your index.html file. The second bucket will be used to redirect to the first one.
Follow the official AWS step-by-step manual to see how you can set up the S3 buckets. But before you follow this manual, you should note the following points:
- Under part 2 of section 2.1, click on “How Do I Create an S3 Bucket?” for the configuration and setup of the S3 bucket.
- Under part 3 of section 2.1, you don’t need to upload the files already. Just add a test index.html file for now.
Pay attention to your endpoint. In your S3 bucket, go to the “Properties” tab and click on the “Static Web Hosting” box. The endpoint will appear similar to this:
4. Setting Up Your Alias Records
Now open your hosted zone by going back to Route 53 in order to add your Alias records. Follow Step 11 in AWS official document to see how it works.
You will be able to see your site as and when the NS settings are set up in 24 hours. Check it out with the URL yourdomain.com. Secure your website by adding an SSL certificate.
5. Getting the SSL Certificate for the Website
Obtain the SSL Certificate with AWS Certificate Manager. To begin, click on “Request or Import a Certificate with ACM.”
Now add both your domain and your subdomain to the certificate and click on “Next.” Do as directed and choose a validation method. Select “DNS validation” and hit the “Review” option. Finally, click on “Confirm and request.”
A Validation page will appear. Click on the arrows next to both domains to see the detailed information. Under each domain, click on “Create a record in Route 53”. This will be used by ACM to validate that you are the owner of those domains.
Click on “Continue.” The validation may take some time, and you will see the states saying “Pending validation” on the console. Once validated, the status will change to “Issued,” and you will be able to see the certificate in the dropdown list in “Custom SSL Certificate.”
Click on “Create Distribution” to set up your CloudFront. It will also take some time, and once AWS does it, you will see the status change from “In Progress” to “Deployed.”
That’s how to host a domain on AWS, fellas! But that’s only for static websites. For dynamic websites, you will need to use EC2.
What are the steps for Hosting a Website on AWS EC2 or Lightsail?
For static websites, AWS uses S3. But if you are wondering how to host a dynamic website on AWS, you will need to use EC2 or Lightsail. Hosting a PHP website on an EC2 instance using Cloudways requires you to follow these steps:
- Launch a server.
- From the dropdown menu, select the “PHP Custom Web Application” option.
- Name your managed app and server.
- Select AWS as your cloud provider.
- Now choose a storage, bandwidth, and server size for your website.
- Select the server location.
- Finally, hit the Launch Now button.
This is for hosting a website for Windows. For Linux, you will need to follow other source guides.
What is the cost of hosting a Dynamic Website on AWS?
A typical dynamic WordPress website hosted by AWS on a reserved instance will only cost as low as $6 per month.
AWS Web Hosting Pricing Plans
AWS is an inexpensive web hosting service. As we all know AWS bills us as per our usage of the resources at any time.
No upfront payments no long-term contracts that are the beauty of using AWS. It offers two options, a pay-as-you-go pricing plan, and a fixed monthly pricing plan.
Most of the static websites will fall under the free-tier option, which is an AWS free web hosting offer for static websites.
Steps for Hosting a Website on AWS Lambda for Free
AWS Lambda is based on the concept of a Serverless Computing platform that can be used to host websites without a server setup. You can easily write code as a Lambda function in any of the supported languages and let AWS Lambda take care of the rest.
The Lambda function can perform anything from calculations and using other AWS services to returning an HTTP response object. Since Lambda operates in response to events, it means that the hosted function will be used whenever an event occurs.
AWS Lambda can take as many as 1 million requests per month. That, too, is for free because the free tier does not expire in 12 months or so.
steps for Hosting WordPress site on AWS
AWS has provided us with a service called Lightsail which can be used to host a WordPress website with a few button clicks. Let’s see step by step approach to doing it:
- Log in to AWS and navigate to Lightsail.
- Create Instance.
- Next, you have to select the Region and the AZ where you like to deploy the instance.
- Select the platform and the blueprint as WordPress.
- Next, choose the plan that suits your budget and requirement for your site.
- Name your instance, and Create an Instance.
- Connect or SSH into your instance from the option available there and run this command to get the WordPress site password – cat $HOME/bitnami_application_password
- This will be used when you connect to the admin console of the WP site.
- In the browser open http://IPAddress/wp-login.php, IP Address is the public IP of the WP site which can be seen on the instance page. Fill in the username as user and the password is the one we obtained in step 7 above.
- It is advisable to use a static IP for your WP site because in case if the instance restarts the IP will change and the site will not be reachable. We can get the same from the Networking tab of the Lightsail page.
- Create a DNS zone on the networking page and use the domain you have registered for your website. This will give a friendly name to your website.
- Yay!! You have just now created a WP website of your own.
how to host php website on AWS
- Launch an EC2 instance with Linux in it.
- While launching make sure the security group has http and https ports opened for access from anywhere.
- Use the ppk/pem file to SSH into the EC2 machine just created using Putty.
- Update your EC2 instance, and install Apache and PHP.
- Make sure to restart the service once the installation is completed.
- Install PHP admin as well now.
- At this point our environment to create a site is ready. So, let us deploy our site now.
- Copy the content of the PHP site to /var/www/html folder in the EC2 machine. You can choose Filezilla to do the copy.
- You have your site up and running, you can open it with the public IP of the EC2 machine.
- If it is a permanent site then give a static Ip to your EC2 machine.
- After that, if you have the domain of your choice make an entry in Route 53 and make an A record to route traffic to your website using your domain name.
Frequently Asked Questions
Q1. What is the Cost of Hosting A Website On AWS?
Well, the cost is a variable factor here and it completely depends on the services used. If you are under the AWS Free Tier, it will be free for you. But if you are outside of the AWS Free Tier, it will cost you roughly $1 to $6 per month.
Q2. Can We Host A Website On AWS?
Anyone can host their website on AWS. AWS also facilitates CDN for your sites for faster response. Any individual, business, group, or government can host their websites on AWS. It is open to all.
Q3. Is Heroku Better Than AWS?
Heroku is only recommended for startups or small businesses. Amazon Web Services (AWS), on the other hand, is ideal for medium businesses and large enterprises.
That’s because Heroku can efficiently handle low computations, whereas AWS can deliver high computation demands.
Q4: How to host a domain on AWS
We can host a domain on AWS using Route 53.
Also, find below the AWS article for more info.
- What Is AWS Lambda
- (Amazon Web Services) AWS Vs Azure
- How Secure Is AWS And How Does It Work
- Overview Of AWS Cloud Management Tools And Usages
- How To Delete AWS Account [Suspended | Partner | Training]
- Introduction To IAM AWS And How It Works
- Introduction To VMWare AWS Hybrid Cloud?
We covered a lot of different ways of hosting sites on AWS. Not only that, we also found out how AWS web hosting pricing works, we saw how to host a website on AWS S3 and EC2, and we answered all your queries regarding AWS web hosting.
Happy reading and watch out for more content!!
I am an Amazon Web Services Professional, having more than 11 years of experience in AWS and other technologies. Extensively working in various AWS tools like S3, Lambda, API, Kinesis, Load Balancers, EKS, ECS, and many more. Working as a Solution Architect and Technology Lead for Architecting and implementing the same for different clients. He provides expert solutions around the world and especially in countries like the United States, Canada, United Kingdom, Australia, New Zealand, etc. Check out the complete profile on About us.