Establishing and improving the website for Champlin Technologies LLC has been a rewarding learning experience. This website has gone through a few major reincarnations using various web-dev tools and webhosts. The original website for Champlin Technologies LLC was dirt simple and hosted with a popular webhost 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).
This website is currently hosted with Amazon Web Services (AWS) with the following observations:
- 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 5-post series with step-by-step procedures that I followed recently to setup WordPress on AWS for this version of the website. As such, this post provides a detailed procedure for me to reuse and for others to reference. I am an advocate of incremental testing – confirming success at intermediate points in a multiple-step complex process.
Note: The Champlin Technologies LLC website is a simple low-maintenance website with low visitor count. Installation and configuration are easy. I will most likely seek the support of experts if I want to establish a sophisticated website that handled commerce or significant traffic with lots of site visitors.
This website will have the following configuration:
- Host: AWS EC2
- Instance: Either a ‘t2.small’ (1 CPU, 2 GB memory, 8 GB disk space) or a ‘t2.micro’ (1 CPU, 1 GB memory, 8 GB disk space), Ubuntu 16.04
- Stack: LAMP (Linux, Apache, MySQL, PHP)
- Website: WordPress with Avada from ThemeFusion
- AMIs: LAMP with initial WP, Fully configured CTLLC (3 month rotation)
From a site maintenance perspective, I will capture an Amazon Machine Image (AMI) of the running instance immediately after the initialization of WordPress. That way, I can quickly (in a few minutes) create a new instance and restore this image to get the LAMP stack with a plain vanilla WordPress installation up and running in a few minutes without going through the installation procedures written below.
On the EC2 dashboard in the following figure, I have two instance sizes (‘t2.small’ and ‘t2.micro’). If you are just starting out with AWS and this is your first instance, AWS provides 12 months of a ‘t2.micro’ instance for free. It is a great way to learn and experiment!
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.
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 and a stopped instance. To create a new instance, start by clicking on ‘Launch Instance’.
- Choose an Amazon Machine Instance (AMI): I usually select the ‘Ubuntu Server 16.04 LTS (HVM), SSD Volume Type’, 64-bit AMI.
- Choose an Instance Type: For this example website, I selected the t2.micro instance which is the same instance size instance as my (My Career Highlights) website. It has one virtual CPU, 1 GB of RAM. However, I use a ‘t2.small’ instance for this website. The cool part is that the ‘t2.micro’ instance is free for the first 12 months. 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 both ‘t2.small’ and ‘t2.micro’ instances is 8 GB. Since these are small websites on a standard LAMP stack, I accept the defaults at this step and click on ‘Next: Add Tags’.
- Add Tags: In the screenshot above, my three instances are named. This is the step where the instance can be named. Note that after the instance is created, the name can be changed at any time from the EC2 dashboard by clicking on the magic pencil in the name field of an instance. Then, 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.
If the instance is not eligible for the free tier usage, there will be a notice about that fact at the top of the screen. Otherwise, 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., example_ami_key) 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 DNS‘ value. For this example, it is ‘ec2-52-43-100-28.us-west-2.compute.amazonaws.com’. It will be used for accessing the instance via SSH.
- Then, move the file to the .ssh folder using ‘Terminal’ using the following command and restrict file permissions with the second command:
mv ~/Downloads/example_ami_key.pem ~/.ssh chmod 400 ~/.ssh/example_ami_key.pem
- Now for the final step – accessing the instance via SSH. Enter the following command to access the instance as ubuntu (default user) with the ‘Public DNS‘ associated with this instance into the Mac OS ‘Terminal’:
ssh -i ~/.ssh/example_ami_key.pem firstname.lastname@example.org
- 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.
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 ‘example_ami_key.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. Start PuTTYgen. 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 ‘example_ami_key.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 ‘example_ami_key.ppk‘ in the same folder as the ‘example_ami_key.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 ‘example_ami_key.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., windows aws) and click ‘Save‘ as shown in the following screenshot.
- Now for the final step. 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 for DNS:
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., 184.108.40.206) 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., dell_micro), and click ‘Associate’. Click the ‘button’ to return to the EC2 dashboard.
At this point, a nice clean static IP address (e.g., 220.127.116.11) is our instance’s IP address.
ssh -i ~/.ssh/example_ami_key.pem email@example.com
And, finally, use a DNS service to assign an actual website name to this elastic IP address. After the DNS website name is established, the website name can replace the Elastic IP address in the SSH command line (Mac) or the IP address in PuTTY (Windows PC).
That’s it. A Linux instance has been established, SSH access works, and the Elastic IP address works.