Migrating my Website to AWS

Table of Contents

In this week’s project walkthrough, I will share my experience migrating my website (nilescript.com) from Bluehost to AWS. First, I will discuss why I chose to migrate the website despite it not having any performance issues with the previous host. I will also discuss the AWS services I used and why I chose them.

Next, I will briefly walk you through the steps involved in the actual migration process for those who may need to undertake a similar process. Finally, I will outline a few challenges I encountered during the migration and how I overcame them. Let’s start with the reasons for Migration. 

Reasons for Migrating from Bluehost to AWS

I have been hosting my website on Bluehost for the last couple of months, and it has been performing well without any issues. By performance, I mean the loading speeds of the site, which are crucial for SEO and overall user experience. My website was receiving traffic of just under 10,000 viewers per month, so I chose one of the cheapest Bluehost plans to save costs. Overall, Bluehost wasn’t a bad hosting option in terms of cost and user experience.

However, since I have been diving deep into AWS and want to explore it further, I decided to shift my site to AWS. I also plan to use AWS for most of my future projects. Migrating my website to AWS allows me to familiarize myself with the platform and take advantage of its wide range of services. Running all my online resources on AWS will also enable me to manage them more efficiently. 

Finally, AWS is a much better platform for long-term scalability than Bluehost. As my website grows and traffic increases, AWS can easily handle the load without compromising performance. AWS is also more cost-effective in the long term. While Bluehost was cost-effective for my initial needs, AWS offers competitive pricing through its Lightsail plans. It also has more advanced features such as access to a global network of data centres for improved performance and reliability.

Choosing AWS Services

For now, my website is simply a blog where I share my experiences in the cloud computing field and other technologies. This means I don’t need a sophisticated AWS architecture to make it work. Instead, I had two viable options to choose from: AWS Lightsail and EC2. 

See also  Technologies That Will Shape the Future Of AI

From these two, I went with Lightsail for the following reasons: 

  • Ease of Use: Lightsail is designed for simplicity. It provides a user-friendly interface that makes it easy to set up and manage a virtual server. This is ideal for my blog, where I don’t need complex configurations or extensive customization.
  • Predictable Pricing: Lightsail offers fixed, predictable monthly pricing. This allows me to plan my expenses easily and avoid unexpected costs. For my current needs, I chose the $7/month plan, which provides 1GB RAM, 2 vCPU cores, 40GB SSD storage, and 1TB data transfer.

For those with more complex setups that require more resource customization and flexibility, AWS EC2 is a better option. It is a more flexible and powerful service. It offers extensive customization options, allowing users to configure the underlying infrastructure according to their specific needs. However, I chose Lightsail because I currently don’t need this level of customization and flexibility. 

Steps Involved in the Migration Process

Step 1: Preparation for Migration

Backing Up the Website: To back up my WordPress site, I used the All-in-One WP Migration plugin. This tool simplifies the backup process by exporting all the website’s files and database into a single backup file that you can save on your computer or a cloud storage service like Google Drive. 

Step 2: Launching the Lightsail Instance

  • Accessing AWS Console: I logged into the AWS Management Console, searched for “Lightsail” in the search bar and selected the “Create instance” option to start the process 
  • Choosing the Operating System: I selected the operating system for my Lightsail instance. In this case, I chose Linux (Ubuntu by Bitnami), as it is a common choice for web hosting. It comes with pre-installed WordPress, Apache Web Server, a database engine, and PHP. 
  • Creating a Key Pair: I created a key pair, which includes a private key and a public key. This key pair is essential for accessing my Lightsail instance securely via SSH. I then downloaded the private key file to my computer. 
  • Choosing the Pricing Plan: As stated earlier, I chose the $7/month plan, which offers adequate resources for my current website needs. 
  • Creating the Instance: After making all the necessary selections, I clicked the “Create instance” button. The instance would take approximately 2 to 5 minutes to be fully operational. Once the instance is ready, it is accessible via the Lightsail Instances page in the AWS Console. Clicking on the instance would open a new page with its details, including the private and public IP addresses.
See also  Deploying WordPress Site on AWS S3 – What You Need to Know

Step 3: Set Up DNS Records

Setting up DNS records is essential to point your domain (e.g., nilescript.com) to your Lightsail server. Here’s a detailed guide on how to do it using Namecheap, though you can use any DNS provider, including AWS Route 53. Using Namecheap as an example, these are the steps I followed: 

  • Log In: Go to the Namecheap website and log in to your account.
  • Navigate to Domain List: From your dashboard, select “Domain List” on the left sidebar to view your registered domains.
  • Select Your Domain: Find the domain you want to configure (e.g., nilescript.com) and click the “Manage” button next to it.
  • Go to Advanced DNS: In the domain settings, select the “Advanced DNS” tab to access DNS management options.
  • Add A Records: To set up DNS records, add an “A Record” for your root domain (e.g., nilescript.com) with the host set to “@” and the Lightsail instance’s Public IP address in the “Value” field. Then, add another “A Record” for the “www” subdomain (e.g., www.nilescript.com) using the same Lightsail Public IP address. Click the checkmark or save button to apply the changes.
  • DNS Propagation: DNS changes may take less than 20 minutes to propagate, but it can sometimes take longer (up to 72 hours). Use tools like DNS Checker to monitor the progress of DNS propagation.

Step 4: Connecting to the Instance

You need to connect to your Lightsail instance to perform further setup and configuration. Follow these steps: 

  • Prepare Your Key Pair: Open Terminal on your machine and Navigate to the Key Pair Directory. Ensure the key file has the correct permissions by running chmod 400 your-key.pem.
  • Connect via SSH: Use this command to connect to your Instance Server via SSH in Terminal: ssh -i/path/to/your-key.pem bitnami@<instance-IP>. If your domain is properly propagated, you can connect using the domain name (like nilescript.com) instead of the public IP address as shown in the above screenshot. 

Step 5: Set Up an SSL Certificate

Adding an SSL certificate ensures that your website uses HTTPS, improving security.

  • Obtain an SSL Certificate: Use bncert-tool: Run the following command on your instance to obtain an SSL certificate from Let’s Encrypt: sudo /opt/bitnami/bncert-tool. The tool will guide you through the process of configuring the SSL certificate for your domain.
  • Verify SSL Certificate: After setting up the DNS and SSL certificate, open your web browser and navigate to your domain (e.g., example.com). You should see your WordPress site with an active SSL certificate indicated by a padlock icon in the address bar.
See also  The AI Boom: A Deep Dive into Its Effects on Global Energy and Climate Change

Step 6: Access WordPress Login

  • Find Login Credentials: While connected to your Lightsail instance, navigate to the root directory. Use the following command to view your WordPress login credentials: cat bitnami_credentials. This command will display your WordPress username and password as shown in the above screen
  • Access Dashboard: Use the credentials obtained to log into your WordPress dashboard and make any necessary changes or updates.

 

Challenges Encountered 

The migration project was relatively straightforward due to my familiarity with AWS. However, I did encounter one notable challenge related to the backup and restoration of my site. When I attempted to restore my site using the All-in-One WP Migration plugin, I encountered a limitation with the free version of the app. The free version restricts the maximum file size for uploads to 80MB, which is way below my website’s size. 

To overcome this issue, I needed a way to handle larger backup files. To handle larger backup files, I used an alternative version of the All-in-One WP Migration plugin that supports unlimited file sizes. I found and downloaded this version from GitHub (follow this link), then uploaded and activated it through the WordPress admin dashboard. This solution allowed me to bypass size limitations and successfully restore my site.