How To Setup Amazon EC2 (AWS) To Host Your Websites

Amazon Web Services (AWS), offered by Amazon, was launched in 2006 and has since become the world’s most popular on-demand cloud computing platform.

It provides a mix of Infrastructure as a Service (IaaS), Platform as a Service (PaaS), and packaged Software as a Service (SaaS) offerings.

For creating virtual servers in the cloud, AWS offers two different solutions: Amazon Elastic Cloud Compute (EC2) and Amazon Lightsail.

Actually, Amazon Lightsail is a simplified version of Amazon EC2, an easy-to-use cloud platform for developers and small businesses. Amazon EC2 is recommended when you need highly configurable environments and instances with consistently high CPU performance for your applications.

In this tutorial, we will focus on Amazon EC2 only. We will show you how to set up an Amazon EC2 server to host your websites (web application).

short video tutorial (less than 3 minutes long) is also included at the end of this tutorial.

Note: If you want to use Amazon Lightsail, please check the other tutorial, how to setup Amazon Lightsail to host your websites.

Step 1. Create an Amazon EC2 Instance

Sign up on the Amazon Web Service (AWS) platform or login to if you already have an account.

Tips: You can use the AWS Free Tier to explore and try out AWS services free of charge up to specified limits for each service. The Free Tier is comprised of three different types of offerings, a 12-month Free Tier, an Always Free offer, and short term trials.

Select AWS Region

When using Amazon EC2, you have to choose the region before you create your Amazon EC2 instance from the top-right menu. Different region has different Amazon EC2 dashboard.

You can choose the region that is close to you or your customers. The closer your instance (server) is to your users, the less latency they will experience.

Currently, AWS has many regions, including N. Virginia, Ohio, N. California, Oregon, Cape Town, Hongkong, Mumbai, Seoul, Singapore, Sydney, Tokyo, Canada, Frankfurt, Ireland, London, Milan, Paris, Stockholm, Bahrain, and Sao Paulo.

Launch Instance

Please go to your Amazon EC2 dashboard, and click the “Instance” menu from the left sidebar. Click the “Launch Instance” button to start creating your server.

Choose Ubuntu Server 16.04 / 18.04 / 20.04

Next, you need to choose an Amazon Machine Image (AMI) for your instance. If you use RunCloud, we supports Ubuntu 16.04, 18.04, and 20.04 LTS at the moment.

For example, type ubuntu on the search form, then select “Ubuntu Server 18.04 LTS (HVM), SSD Volume Type”.

Choose Amazon EC2 Instance Type

Under the “Instance Type” option, select one of the predefined instance types for your instance. Each machine type gives you a certain number of vCPUs (virtual Central Processing Unit) and the amount of memory.

For example, you can choose t2.micro instance with 1 vCPU and 1GB Memory that is currently eligible for AWS free tier.

Add Storage

Under storage option, you can configure the storage of your server. There are 3 volume types: General Purpose SSD, Provisioned IOPS SSD, and Magnetic storage.

Free tier eligible customers can get up to 30 GB of EBS General Purpose (SSD) or Magnetic storage.

Configure Security Group (Open Required Ports)

This step is very important so that your Amazon EC2 instance is accessible on the internet.

You should open at least 4 ports:

  • SSH – TCP Port 22
  • HTTP – TCP Port 80
  • HTTPS – TCP Port 443
  • Custom – TCP Port 34210

If you use RunCloud and want to connect your server to RunCloud, you need to open TCP port 34210 in order to allow RunCloud to communicate with your Amazon EC2 instance.

Create and Download a Key Pair

After clicking the “Launch” button, Amazon EC2 will ask you to select an existing key pair or create a new key pair.

This key pair is very important for you to allow you to connect to your server securely. We will use it in the next step to login to your server.

Please create a new key pair and save it to your local computer. You will not able to download the file again after it’s created.

Step 2. Create A Static Public IP Address

The auto-assigned public IP address associated with your Amazon EC2 instance changes every time you stop and start the instance.

If you use Amazon EC2 to host your website, it is highly recommended to use the static IP address for your server. Amazon EC2 has provided an Elastic IP address feature for this purpose. Unlike the auto-assigned public IP address, an Elastic IP address is preserved after you stop and start your instance.

Note: By default, all AWS accounts are limited to five (5) Elastic IP addresses per region. If you think you need more than 5 Elastic IP addresses in your AWS account, you can request a quota increase directly from the AWS Service Quotas console.

Allocate Elastic IP Address

Go to the “Network & Security” – “Elastic IPs” menu.

Click the “Allocate Elastic IP address” button to create a static IP address for your server.

Associate Elastic IP Address To Amazon EC2 Instance

After creating an Elastic IP address, you can continue to click the “Associate Elastic IP address” button and select your instance to use this Elastic IP address.

Now your Amazon EC2 instance has a static IP address and ready to use to host your websites.

Step 3. Connect Amazon EC2 Instance To RunCloud

Why Should You Use RunCloud?

AWS has many tutorials about how to host your website using Amazon EC2, for example:

Then why should you use RunCloud to set up your Amazon EC2 server?

  • RunCloud simplifies server management experience. Either using Amazon EC2 other providers, you only need to master RunCloud once for all cloud server providers. You don’t need to be a Linux expert to build a website powered by Amazon EC2.
  • You can easily manage multiple servers (Amazon EC2 and others) from one single RunCloud dashboard.
  • You can manage multiple web applications (websites) in one server using RunCloud.
  • You can easily change the web application stack from native Nginx to Nginx-Apache2 hybrid and vice versa for each web application in your server. No need to spin a new server only to try to use Nginx or Apache.
  • You can easily change the PHP version (7.0, 7.1, 7.2, 7.3, 7.4) of each web application in your server anytime. A different web application may require a different PHP version and no need to spin a new server to host another website with a different PHP version.
  • You can easily set up Let’s Encrypt SSL/TLS (https) to secure every web application in your server. RunCloud also supports wildcard Let’s Encrypt SSL and custom certificate.
  • You can easily clone your web application in the same server or to other servers in your RunCloud dashboard.
  • You can get notification from RunCloud server health monitoring when server load is high, RAM memory is nearly full, and disk space is low, directly to your email, telegram, or slack.
  • RunCloud supports many web applications, including WordPress (one-click install), Laravel, and any PHP web applications.
  • For WordPress users, you can use RunCloud Hub to optimize your website with server-side page caching and Redis object cache.
  • For professional WordPress developers, you can use the one-click WordPress Staging feature to create a staging version of your website easily.
  • For professional developers, you can use Git deployment from Github, BitBucket, Gitlab, to deploy your web application easily.
  • For power users, you can use the Custom Nginx Config feature to customize Nginx easily from the RunCloud dashboard, without having to edit it manually.
  • For agencies, you can use our Team feature to assign a different team member to a different server with separate permission.

If you still do not have a RunCloud account, please register for 5 days free trial, no credit required.

Get Started With RunCloud

Connecting your Amazon EC2 server to RunCloud is very easy. RunCloud provides three different methods for connecting your cloud servers.

For Amazon EC2, you can use the manual server installation method.

Connect Your Server

ou can log in to the RunCloud dashboard and click the “Connect a new server” button. Please select Amazon Web Service from the Server Provider list.

Please add a server name and static IP address that you have created on Step 2. Click the “Add this server” button.

Choose Manual Installation

On the next screen, you can choose “Manual Installation” and you will see the script that you have to run on your Amazon EC2 instance.

Login / Connect To Amazon EC2 Instance

You can go back to the Amazon EC2 dashboard and find your server under the Instances menu.

Select the instance and click on the “Connect” button at the top to see the instructions.

You will see there are 3 connection methods:

  • A standalone SSH client
  • Session Manager
  • EC2 Instance Connect (browser-based SSH connection)

In this tutorial, we will show you how to use a standalone SSH client to connect to your Amazon EC2 instance.

Connect Using Standalone SSH Client

Amazon EC2 has provided complete instruction to connect using a standalone SSH client. You only need to follow the steps.

Please open an SSH client and go to the directory where you saved the key pair that has been downloaded from Step 1 above.

From this directory, you can run this command to make the key pair is not publicly viewable for SSH to work.

chmod 400 mykeypairname.pem

Then connect to your instance using its Public DNS.

ssh -i "mykeypairname.pem" ubuntu@myamazonec2-public-dns

You can copy & paste the example code that has been provided on the instruction.

Run RunCloud Installation Script

We need to run the RunCloud installation script command as “root” user. Please run the command below to start a “root” shell.

sudo -s

Then, paste and run the RunCloud installer script command.

The RunCloud installation will take a few minutes to complete.

You can check the installer progress at the RunCloud panel too.

Once it is completed, you will see the MySQL root password for your database management and the “runcloud” system user password. Please save this information.

If successful, data about your server will appear, and you have successfully set up your Amazon EC2 server with RunCloud.

Video Tutorial – Setup Amazon EC2 (AWS) With RunCloud

You can watch this short video tutorial to show you all steps that we have explained above in less than 3 minutes.

Next Step

After setting up your server, you can continue to:

Categories: Server Management, Tutorials

Simplifying Server Management

RunCloud is a cloud server management tool that allows you to maintain full control of your server and host multiple WordPress, WooCommerce, Laravel, and PHP applications with fast and easy configuration.

Start Your Free Trial

5 days free trial no credit card required cancel anytime

Leave a Comment

Your email address will not be published. Required fields are marked *