Updated: November 2020

Overview:

Establishing and improving websites by Champlin Technologies LLC have been rewarding learning experiences. Specifically, this website has gone through a some major reincarnations using various web-dev tools and hosting webservers. The original website for Champlin Technologies LLC (2014) was dirt simple and hosted with a popular webhosting service that didn’t deliver on two important metrics: load-time (over 12 seconds for initial load time for home page) and up-time (down for several hours each month).

All our websites are currently hosted with Amazon Web Services (AWS) and have the following metrics:

  • Performance is now quick (load time is less than 1 second for first view, less than 0.4 seconds for repeat views).
  • Availability is unbelievably impressive.
  • Solution is affordable.

As I can affirm, establishing a website on AWS EC2 can be a little intimidating at first to setup, configure, backup, and operate … even for people with good Linux and IT skills. Fortunately, effective help is just a few clicks away. This post is the first of a 6-post series with step-by-step procedures that I follow to setup WordPress on AWS for websites. As such, these posts provide a detailed procedure for me to reuse and for others to reference. As with all projects, I am an advocate of incremental testing – confirming success at intermediate points in a multiple-step complex process.

Note: The original version for this series was written in 2016 with EC2 servers running Ubuntu 16.04. This series has been completely updated in late 2020. An example website, Seattle Hobbies, will be used throughout this series. The development of the Seattle Hobbies website assumes a simple low-maintenance website with low visitor count with no auto-scaling or redundancy. As such, implementation and configuration are easy. I will most likely seek the support of web-dev experts if I want to establish a more sophisticated website that handles commerce or has significant traffic with lots of site visitors.

Configuration Overview:

This example simple website will have the following configuration:

  • Host: AWS EC2
  • Instance: Ubuntu 20.04 running on a 64-bit ARM ‘t4g.micro’ instance (1 CPU, 1 GB memory, 8 GB disk space),
  • Stack: LAMP (Linux, Apache, MySQL, PHP)
  • Website: WordPress with Avada theme from ThemeFusion

AWS Account:

If an AWS account needs to be established, then go to Amazon Web Services (AWS), click on ‘Sign in to the Console’, and follow the steps to create an account.

DNS Name Search and Purchase:

Each website has a name registered with DNS. And, this website is no different. Availability of website names makes the search and selection process a little challenging. ‘Route 53’ is the AWS service that allows for searching for an available website name from a DNS and purchasing it. The ‘Route 53’ service can be accessed from the AWS ‘Services’ on the top menu by clicking on ‘Route 53’ under ‘Networking & Content Delivery’. Select ‘Registered domains’ from the left column menu and then, click on ‘Register domain’ button.

At this point, enter the desired name for the website to check for its availability. For this series, the name ‘thehobbyapp.com’ was unavailable as shown below. However, the choice of ‘seattlehobbies.com’ was available. Add to cart, fill in contact info and purchase.

Typically, it takes from 15 to 45 minutes for DNS to register the website name. In the meantime, an instance needs to be created.

Launching an AWS Ubuntu Instance:

To create a new instance, sign into AWS and click on ‘Services’ on the top menu, then click on ‘EC2’ located under ‘Compute’. Then click on ‘Instances’ from the left column on the EC2 Dashboard. The screenshot shows a portion of my EC2 dashboard with two running instances on old ‘t2’ instances. To create a new instance, start by clicking on ‘Launch Instance’.

  • Choose an Amazon Machine Instance (AMI): I usually select the ‘Ubuntu Server 20.04 LTS (HVM), SSD Volume Type’, 64-bit ARM. Selecting 64-bit ARM supports the ‘t4g’ instances.
  • Choose an Instance Type: Although I am selecting a t4g.micro instance for this Seattle Hobbies example website, I recommend a t4g.small instance as a minimum size. When I was implementing a WordPress site using an Avada theme on a t4g.micro, the instance ran into memory problems and crashed 3 times within a few hours of website design. I then restored the instance’s image to a t4g.small instance that has twice the memory of a t4g.micro instance and didn’t see any more issues. Then, click on ‘Next: Configure Instance Details’.
  • Configure Instance Details: I usually accept the defaults at this step and click on ‘Next: Add Storage’.
  • Add Storage: The standard amount of disk space for the ‘t4g.micro’ instance is 8 GB. Since this is a small website with a standard LAMP stack, I accept the defaults at this step and click on ‘Next: Add Tags’.
  • Add Tags: In the screenshot above, my two instances are named. Although this is the step where the instance can be named, the instance name can be changed at any time from the EC2 dashboard by clicking on the magic pencil in the name field of an instance. Click on ‘Next: Configure Security Group’.
  • Configure Security Group: Create a new security group (e.g., example-security-1) and add the following rules to this new security group, then, click on ‘Review and Launch’. The next screen will provide a warning about the ‘open to the world’ security group settings. For this example, it is acceptable, but for a commercial grade website, it is advisable to learn more about security group settings and apply them to the instance.
  • Review the configuration summary and click on ‘Launch’. This is the key step (pun intended) in the launch process. SSH access via a command line interface (e.g., terminal on the Mac or PuTTY on Windows) to the AWS instance is not with a password but with a public/private encryption key pair. Select ‘Create a new key pair’, type in a relevant filename (e.g., seattlehobbies) and click on ‘Download Key Pair’.
  • After the key file has been downloaded, it is time to launch this instance. Click on ‘Launch Instances’. Going back to the EC2 dashboard as shown in the first screenshot, a new instance will start initializing. After a few minutes, it will be running as shown in the following screenshot:
  • Make a note of the ‘Public IPv4 DNS‘ value. For this example, it is ‘ec2-44-234-120-177.us-west-2.compute.amazonaws.com’. It will be used for accessing the instance via SSH.

If a Mac is being used to access AWS, the private key is sent to the Mac OS ‘Downloads’ folder with the following example filename: ‘seattlehobbies.pem’.

  • Move the file to the .ssh folder using ‘Terminal’ using the following command and restrict file permissions with the second command:
mv ~/Downloads/seattlehobbies.pem ~/.ssh
chmod 400 ~/.ssh/seattlehobbies.pem
  • Access the instance via SSH. Enter the following command to access the instance as ubuntu (default user) with the ‘Public IPv4 DNS‘ associated with this instance into the Mac OS ‘Terminal’:
ssh -i ~/.ssh/seattlehobbies.pem ubuntu@ec2-44-242-122-237.us-west-2.compute.amazonaws.com
  • On first launch, the AWS instance may ask to verify. Type ‘yes’ and return. A successful login screen will look similar to:

  • Type ‘exit’ to quit the SSH connection.

If a Windows PC is being used to access AWS, the private key is sent to the Windows ‘Downloads’ folder with the following filename: ‘seattlehobbies.pem’.

Accessing the AWS instance from a Windows PC is accomplished with a software program such as PuTTY. Here are the steps to install, generate a compatible private key file, configure settings, and connect to the AWS instance using PuTTY:

  • Install: Download the 64-bit MSI installer from PuTTY. Windows will ask what to do with the file and ask again if you want to run the file. Select ‘Run’ each time and follow the prompts to install PuTTY.
  • Generate a compatible private key file: The private key file ‘seattlehobbies.pem‘ needs to be converted to a ‘*.ppk‘ by PuTTYgen. PuTTYgen is one of the software programs that was created during the installation process with PuTTY. Locate PuTTYgen in the Windows app menu as shown below and double-click to launch it.

    Set the ‘Type of key to generate:‘ to RSA and the ‘Number of bits in a generated key:‘ to 2048 as shown in the following screenshot. Then, click on ‘Load‘ to load the recently downloaded private key file. Since the file type we are looking for is a ‘*.pem‘ file, select ‘All Files (*.*)‘ so that it will be visible. Then, go to the ‘Downloads’ folder and select ‘seattlehobbies.pem‘ and click ‘OK‘ on the displayed notice. Click ‘Save private key‘ and click ‘Yes‘ to confirm saving without a passphrase key. Then, save the ‘seattlehobbies.ppk‘ in the same folder as the ‘seattlehobbies.pem‘ file. Close ‘PuTTYgen‘ software program.

  • Configure settings: PuTTY is one of the software programs that was created during the installation process with PuTTY. Start PuTTY. In the left pane, select ‘Connection -> SSH -> Auth‘. Click on ‘Browse‘ and select the ‘seattlehobbies.ppk‘ as shown in the following screenshot.

  • Then, in the left pane, select ‘Session‘. In the right pane, confirm or select ‘SSH‘, port is 22, and type in the ‘ubuntu@‘ followed by the ‘Public DNS‘ associated with this instance. At this point, type in a name for ‘Saved Sessions‘ (e.g., Seattle Hobbies) and click ‘Save‘ as shown in the following screenshot.

  • To access the instance via SSH using PuTTY, load a saved session and click on ‘Open‘ (may need to confirm yes on initial login using this IP address). A successful login screen to the AWS instance from PuTTY will look similar to:

  • Type ‘exit’ to quit the SSH connection to AWS which will also close PuTTY.

Setting up an Elastic IP Address:

An Elastic IP address (i.e., static public IP for the website) is needed to associate a website name via a DNS (domain name service). Click on the ‘Elastic IPs’ topic located on the left column of the EC2 dashboard. Then, click on ‘Allocate New Address’ and confirm the allocation request by clicking on ‘Allocate’. An Elastic IP address is immediately allocated. Associate the Elastic IP address (e.g., 44.242.122.237) to the instance by highlighting the address and selecting ‘Associate Address’ from the ‘Actions’ pull-down menu. Click in the ‘Instance’ field, associate the instance (e.g., seattlehobbies), and click ‘Associate’. Click the ‘button’ to return to the EC2 dashboard.

At this point, a nice clean static IP address (e.g., 44.242.122.237) is our Seattle Hobbies instance’s IP address.

Open a new Terminal window and enter the following command with the new Elastic IP address (may need to confirm yes on initial login using this elastic IP):

ssh -i ~/.ssh/seattlehobbies.pem ubuntu@44.242.122.237
Start PuTTY and load a saved session (e.g., windows aws). Change the ‘Host Name (or IP address)‘ to the elastic IP address (e.g., ‘unbuntu@44.242.122.237)‘ and save the session. Then, click ‘Open‘ as before to start a SSH session with the AWS instance (may need to confirm yes on initial login using this elastic IP).

Associate an Elastic IP to DNS:

To associate an Elastic IP to the DNS website name, go back to AWS ‘Route 53’ service and click on ‘Hosted Zones’. Select the ‘Domain name’ corresponding to the website (e.g., ‘seattlehobbies’).

To associate an Elastic IP to the DNS website name, create an ‘A’ record for the hosted zone. Click on ‘Create record’, select ‘Simple routing from the array of choices’ and click ‘Next’. Since this is a simple example, click on ‘Define a simple record’. As shown in the screenshot below, leave ‘Record name’ blank, choose endpoint under ‘Value/Route traffic to’, and enter the Elastic IP address (e.g., 44.242.122.237). Record type should be ‘A – Routes traffic to an IPv4 address and some AWS resources’. Click on ‘Define simple record’ and click on ‘Create records’.

In addition, the Elastic IP needs to be associated with the ‘www’ sub-domain of the DNS website name. Repeat the steps above, but fill in ‘Record name’ with ‘www’ as shown in the screenshot below:

After both record are created, the records table should have entries similar to the table below:

It will take several minutes before the website names, records, and IP address are propagated through DNS.
After the DNS website name is associated, the website name can replace the Elastic IP address in the SSH command line (Mac) or the IP address in PuTTY (Windows PC).

Since package updates to Ubuntu occur frequently, the initial Ubuntu 20.04 needs to process any updates. Follow the update steps listed in this blog post: A Collection of AWS EC2 Ubuntu Tips

That’s it. A Linux instance has been established and SSH access works with the DNS website name ‘seattlehobbies.com’.