How to Host a Dynamic Website on AWS: A Step-by-Step Guide

Whether you run a small business or a Fortune 500 company, good web hosting is critical. In the last few years, many businesses have been looking at ways to cut costs while improving efficiency.

This has given rise to the popularity of Amazon’s Cloud hosting services through Amazon Web Services (AWS).

It may be confusing to find out how to host a dynamic website on AWS if you don’t have much experience with the platform.

AWS has multiple options available to get you hosting your dynamic website. The option you choose will depend on what you need your website to do and how much control you want.

With a bit of knowledge and know-how, you can soon be hosting a powerful website on AWS by following a few simple steps.

As someone who has looked into many different hosting options over the years, I am intrigued by Amazon’s services. Its platform seems to work well and provides scalability, affordability and security, which are critical for growing your business.

In this article, we will be covering a few topics related to hosting a website on AWS. Here is a short preview of what is to come:

Web Hosting Options Available on AWS

It might seem challenging to choose which option to use as many of the features seem to overlap. However, I am highlighting the four most popular options for hosting a website on AWS. 

WordPress on Lightsail

WordPress is one of the most popular hosting platforms. It’s popular with users who need a bit more help and hand-holding for their hosting needs. AWS Lightsail is a straightforward way to start hosting a website quickly, at a relatively fixed price.

You might experience limitations with scalability, security and how much control you have over your website.

Amplify

AWS Amplify is one of the newer hosting products offered by Amazon. It aims to provide a seamless developer workflow through the command-line interface (CLI).

The platform gives you access to AWS resources that you can interact with through the Amplify CLI.

By using Amplify, you can implement a comprehensive AWS infrastructure so that users can build rich websites with lots of different functionality. 

Elastic Beanstalk

Elastic Beanstalk can be described as a hybrid between Amplify and Lightsail.

It’s excellent for AWS web hosting for developers who only want to worry about uploading the code for their web app.

Elastic Beanstalk will automatically allocate resources, load balancing, auto-scaling, networking, and security. This way, the developer can solely focus on developing a web application. 

EC2 and ECS

EC2 and ECS are used to build large scale distributed systems that can handle millions of users and thousands of transactions per minute.

EC2 stands for Elastic Compute Cloud and is probably Amazon’s oldest hosting solution. ESC stands for Elastic Container Service and works great if you are also using Docker.

Both EC2 and ECS are ideal for hosting a website on AWS, if you plan to scale the website as you grow since the scaling abilities of these options are nearly limitless.

However, with EC2, be aware that you will be in charge of setting up all the infrastructure. This includes security, Apache, patches and more.

Benefits of Hosting Websites on AWS

Now that we know the available options for AWS web hosting, let’s look at a few reasons you would want to use AWS to host your website.

Control

AWS website hosting gives you much more administrative control of your virtual servers, also known as ‘’compute instances.’’

If you were to go with EC2, you would have complete control over every aspect of your infrastructure.

Ease of Access

AWS web hosting provides the same level of server access as a physical server located in large offices. Users are also able to easily manage many different web features directly from the AWS console.

This makes scaling, booting up and down, and configuring processor settings easier.

Choose Your Platform

When launching applications with AWS, especially when using EC2, you can decide which operating system you want to run on.

This might not make much difference to someone just needing to host a quick website, but if you’re a big business, it can mean a lot. 

For example, if you were a big company that used a Windows server and stored developed apps and databases on this framework, you wouldn’t have to spend time and money to reprogram your entire IT infrastructure just to run on another platform.  

Security

By having more control of your infrastructure, you also have more control over your security features.

Regardless of whether you choose a package that takes care of the security features or if you want complete control, you will have access to AWS security groups. 

How to Host a Website on AWS

Now, we can start looking at how to host a dynamic website on AWS. The steps we share below will help you set up web hosting for an effective website through EC2.

I chose EC2 because it offered more control and the scalability I would need down the line. 

Step 1: Log Into the AWS Console

The first thing you would need to do is log in to your AWS Management Console, as this is where all the work will be taking place.

aws web hosting
The AWS Management Console

Step 2: Create a Bucket

A bucket provides object storage through a web service interface such as S3 from AWS. To create a bucket, you navigate to S3 or Simple Storage Service.

Once there, you can create a new bucket. You can use the default settings if you’re a beginner. However, feel free to change the settings to meet your requirements. 

hosting a website on aws
Creating a bucket in the AWS Management Console.

Step 3: Load Your Website Files to the Bucket 

Next, you will need to upload a zip file containing your website (your PHP, JS and CSS files).

If your file is not compressed, zip it first before uploading it to your bucket on AWS Management Console.

Make your bucket public when setting it up. To do this, you select your bucket and click on ‘’Edit Public Access Settings’’ and confirm that the ‘’Block All Public Access’’ tab is unchecked.

You will also need to make the zip file you uploaded public. To do this, you go into the bucket and select the zip file. In the above menu, click on ‘’Actions’’ and then click on ‘’Make Public.’’

Step 4: Launch an Instance

Launch an instance by clicking on ‘’EC2’’ under Compute services in your console. You will be taken to a Window showing any existing instances. From here, you click on ‘‘Launch Instance.’’ 

Next, you will need to choose which machine image you want to use from the options provided. Then you go through the settings.

You can customize them to your needs or leave the default settings as you go through the options. 

On the ‘‘Add Tags’’ section, you can add a name for your instance so that you can easily identify it. Next, in the ‘‘Security Group’’ section, make sure to add both HTTP and HTTPS by clicking on ‘‘Add Rule.’’ 

Now you can review your instance. If you are happy to launch it, you will be asked to select an existing key pair or create a new one. If you are unsure whether you have one, create a new one and save this download because you will need it in future.

Step 5: Copy Your Public IP

Once your instance has been created, select it. In the bottom window showing the instance’s details, copy the IPv4 Public IP to your clipboard.

This will be needed in the upcoming steps.

Step 6: Connect to the Instance Using PuTTy (or Similar)

Next, you will need to use an SSH and Telnet client such as PuTTy. This plugin is used to add the SSH of your website to the instance.

To start using PuTTy in the section’s Host Name (or IP Address), type: ‘‘EC2-user@’’ and then paste the Public IP you copied in step 5.

EC2-user@

Next, you need to navigate to the SSH section in PuTTy, then select ‘‘Auth.’’ Here you will need to add your key pair that you downloaded in step 4.

Once you’ve added your key pair, you can click on open. You will now be in the command screen for your instance.

Step 7: Update the Server

First, you will need to update the server of your instance. To do this type, ‘‘sudo su’’’ and press Enter to go to the root directory.

Next, type in ‘‘yum update -y’’’ and press Enter. This will install all available patches and update your EC2 instance.

yum update -y
Updating the server for a AWS EC2 Instance through PuTTY.

Step 8: Install Apache

Once the server update has finished, you will need to install Apache. To do this, type ‘‘yum install httpd -y’’ and press Enter. 

yum install httpd -y

Step 9: Start Uploading Web Pages

First you need to type ‘‘cd/var/www/html.’’’ Now that we are in the right directory, ie. HTML, we need to add our zip folder from the bucket we created in step 2.

Navigate back to your AWS console and select your bucket. Open the bucket, and at the bottom, copy the object URL.

Go back to PuTTy and type ‘‘wget’’ and paste the object URL here and press Enter. This will download the zip file.

wget

Next, you will need to unzip the file. To do this, you type ‘‘unzip’’ followed by the folder name. You would have to type the file name exactly as it appears, including capital letters if you used them.

If you want to see the folder name, you can type in ‘‘ls’’ and press enter, and the name of the zip folder will show on the screen.
Now we will need to move the files contained in the unzipped folder to the directory. Type in ‘‘mv filename/*.’’ You can type in ‘‘ls’’ to check that all the files have been moved directly to this directory.

hosting website on aws
Moving files into the correct directory in PuTTy.

The last step is to type in ‘‘service httpd start’’ so that Apache can upload everything to the instance. To test the website, you can copy the IPv4 Public IP of the instance and paste it into your address bar, and your website should run.

service httpd start

The Bottom Line

As you can see, there are many benefits to hosting a website on AWS. Also, learning how to host a dynamic website on AWS is not as challenging as it may appear. I found the process relatively simple to follow, especially if you have a bit of back-end knowledge.

By following the above steps, you can start hosting your website directly through AWS, meaning that you can grow, expand and scale your website to your heart’s content. 

Make sure to check out AWS’s hosting services, and you’ll soon see how much they offer in terms of complete cloud services. Get started by hosting your website on AWS now.

Leave a Comment