How to host a website on AWS EC2 Windows

Last updated: 2021-02-03

I want to host multiple public websites using Internet Information Services (IIS) on a single Amazon Elastic Compute Cloud (Amazon EC2) Windows Server instance. How can I do that?

Resolution

If you have more than one website, you can host them in IIS on the same EC2 Windows Server instance. IIS differentiates between websites by using bindings, which are a combination of the protocol type, IP address, port, and hostname. To avoid IP and port conflicts, you must add a hostname.

Follow these steps to configure the IIS server on your instance to host multiple websites:

  1. If you haven't already done so, set up and configure your websites on the EC2 Windows Server instance. Make sure to install and configure IIS on the instance.
  2. Use the Amazon EC2 console to get the IP addresses of the EC2 Windows Server instance.
  3. Connect to the instance using Remote Desktop Protocol (RDP).
  4. Open IIS Manager, and in the Connections pane, choose the site that you want to add a host name to.
  5. In the Actions pane, choose Bindings, Edit, enter a name in the host name field, and then choose OK.
  6. Update the hosts file with the host name to access the website locally from the IIS server:
    Open a text editor using the Run as Administrator option, and then open the hosts file in the C:\Windows\System32\drivers\etc directory.
    Enter the Private IP address of the EC2 instance and the host name of your website, and then save the file.
  7. Repeat steps 4 through 6 for each additional website.

Now your websites can be accessed using the private IP address locally from the hosts file on the same EC2 Windows Server instance. For public access, add the public IP address in your public hosted zone through your DNS host provider or with Amazon Route 53.


Did this article help?


Do you need billing or technical support?

AWS support for Internet Explorer ends on 07/31/2022. Supported browsers are Chrome, Firefox, Edge, and Safari. Learn more »

Use this tutorial to get started with Amazon Elastic Compute Cloud (Amazon EC2). You'll learn how to launch, connect to, and use a Windows instance. An instance is a virtual server in the AWS Cloud. With Amazon EC2, you can set up and configure the operating system and applications that run on your instance.

When you sign up for AWS, you can get started with Amazon EC2 using the AWS Free Tier. If you created your AWS account less than 12 months ago, and have not already exceeded the free tier benefits for Amazon EC2, it won't cost you anything to complete this tutorial because we help you select options that are within the free tier benefits. Otherwise, you'll incur the standard Amazon EC2 usage fees from the time that you launch the instance until you terminate the instance (which is the final task of this tutorial), even if it remains idle.

Related tutorials

  • If you'd prefer to launch a Linux instance, see this tutorial in the Amazon EC2 User Guide for Linux Instances: Get started with Amazon EC2 Linux instances.

  • If you'd prefer to use the command line, see this tutorial in the AWS Command Line Interface User Guide: Using Amazon EC2 through the AWS CLI.

Contents

  • Overview
  • Prerequisites
  • Step 1: Launch an instance
  • Step 2: Connect to your instance
  • Step 3: Clean up your instance
  • Next steps

Overview

The instance launched in this tutorial is an Amazon EBS-backed instance (meaning that the root volume is an EBS volume). You can either specify the Availability Zone in which your instance runs, or let Amazon EC2 select an Availability Zone for you. Availability Zones are multiple, isolated locations within each Region. You can think of an Availability Zone as an isolated data center.

When you launch your instance, you secure it by specifying a key pair (to prove your identity) and a security group (which acts as a virtual firewall to control ingoing and outgoing traffic). When you connect to your instance, you must provide the private key of the key pair that you specified when you launched your instance.

How to host a website on AWS EC2 Windows

Prerequisites

Before you begin, be sure that you've completed the steps in Set up to use Amazon EC2.

Step 1: Launch an instance

You can launch a Windows instance using the AWS Management Console as described in the following procedure. This tutorial is intended to help you quickly launch your first instance, so it doesn't cover all possible options. For information about advanced options, see Launch an instance using the new launch instance wizard. For information about other ways to launch your instance, see Launch your instance.

To launch an instance

  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. From the EC2 console dashboard, in the Launch instance box, choose Launch instance, and then choose Launch instance from the options that appear.

  3. Under Name and tags, for Name, enter a descriptive name for your instance.

  4. Under Application and OS Images (Amazon Machine Image), do the following:

    1. Choose Quick Start, and then choose Windows. This is the operating system (OS) for your instance.

    2. From Amazon Machine Image (AMI), select the AMI for Windows Server 2016 Base or later.. Notice that these AMIs are marked Free tier eligible. An Amazon Machine Image (AMI) is a basic configuration that serves as a template for your instance.

  5. Under Instance type, from the Instance type list, you can select the hardware configuration for your instance. Choose the t2.micro instance type, which is selected by default. The t2.micro instance type is eligible for the free tier. In Regions where t2.micro is unavailable, you can use a t3.micro instance under the free tier. For more information, see AWS Free Tier .

  6. Under Key pair (login), for Key pair name, choose the key pair that you created when getting set up. Note that you must select an RSA key. ED25519 keys are not supported for Windows instances.

    Do not choose Proceed without a key pair (Not recommended). If you launch your instance without a key pair, then you can't connect to it.

  7. Next to Network settings, choose Edit. For Security group name, you'll see that the wizard created and selected a security group for you. You can use this security group, or alternatively you can select the security group that you created when getting set up using the following steps:

    1. Choose Select existing security group.

    2. From Common security groups, choose your security group from the list of existing security groups.

  8. Keep the default selections for the other configuration settings for your instance.

  9. Review a summary of your instance configuration in the Summary panel, and when you're ready, choose Launch instance.

  10. A confirmation page lets you know that your instance is launching. Choose View all instances to close the confirmation page and return to the console.

  11. On the Instances screen, you can view the status of the launch. It takes a short time for an instance to launch. When you launch an instance, its initial state is pending. After the instance starts, its state changes to running and it receives a public DNS name. If the Public IPv4 DNS column is hidden, choose the settings icon (

    How to host a website on AWS EC2 Windows
    ) in the top-right corner, toggle on Public IPv4 DNS, and choose Confirm.

  12. It can take a few minutes for the instance to be ready for you to connect to it. Check that your instance has passed its status checks; you can view this information in the Status check column.

Step 2: Connect to your instance

To connect to a Windows instance, you must retrieve the initial administrator password and then enter this password when you connect to your instance using Remote Desktop. It takes a few minutes after instance launch before this password is available.

The name of the administrator account depends on the language of the operating system. For example, for English, it's Administrator, for French it's Administrateur, and for Portuguese it's Administrador. For more information, see Localized Names for Administrator Account in Windows in the Microsoft TechNet Wiki.

If you've joined your instance to a domain, you can connect to your instance using domain credentials you've defined in AWS Directory Service. On the Remote Desktop login screen, instead of using the local computer name and the generated password, use the fully-qualified user name for the administrator (for example, corp.example.com\Admin), and the password for this account.

If you receive an error while attempting to connect to your instance, see Remote Desktop can't connect to the remote computer.

Step 3: Clean up your instance

After you've finished with the instance that you created for this tutorial, you should clean up by terminating the instance. If you want to do more with this instance before you clean up, see Next steps.

Terminating an instance effectively deletes it; you can't reconnect to an instance after you've terminated it.

If you launched an instance that is not within the AWS Free Tier, you'll stop incurring charges for that instance as soon as the instance status changes to shutting down or terminated. To keep your instance for later, but not incur charges, you can stop the instance now and then start it again later. For more information, see Stop and start your instance.

To terminate your instance

  1. In the navigation pane, choose Instances. In the list of instances, select the instance.

  2. Choose Instance state, Terminate instance.

  3. Choose Terminate when prompted for confirmation.

    Amazon EC2 shuts down and terminates your instance. After your instance is terminated, it remains visible on the console for a short while, and then the entry is automatically deleted. You cannot remove the terminated instance from the console display yourself.

Next steps

After you start your instance, you might want to try some of the following exercises:

  • Learn how to remotely manage your EC2 instance using Run Command. For more information, see AWS Systems Manager Run Command in the AWS Systems Manager User Guide.

  • Configure a CloudWatch alarm to notify you if your usage exceeds the Free Tier. For more information, see Tracking your AWS Free Tier usage in the AWS Billing User Guide.

  • Add an EBS volume. For more information, see Create an Amazon EBS volume and Attach an Amazon EBS volume to an instance.

How do I host a website on AWS EC2?

Following are the steps as to how to host a website on AWS EC2, in this case, a PHP web app; Launch a server as per your requirements and traffic needs of your website (You can always scale it later.) Select PHP Custom Web Application from the dropdown. Give a name to your managed app, and managed server.

How do I host an EC2 instance in Windows?

In a browser, type your public IP address and ensure that you can access the website from the outside. Use a static public Elastic IP address to access your website from a host name. Open the EC2 console first, and then select Elastic IPs from the navigation pane. Select Allocate new address, then Allocate, then Close.

Can you run Windows on EC2?

Using Amazon EC2 with Windows Server is similar to using Amazon EC2 with any other operating system. Amazon EC2 running Windows Server provides seamless integration with existing Amazon EC2 features like Amazon Elastic Block Store (EBS), Amazon CloudWatch, Elastic Load Balancing, and Elastic IPs.

Can you host a static website on EC2?

You just follow the below steps and host your website . Go to your AWS account and sign in to console. Search ec2 service in service bar and launch ec2 instance . Connect to your ec2 instance and change your user local to root with the help op “ sudo su ” command.