How to Migrate WordPress to AWS

November 21, 2017Leron AminComments Open

Interested in hosting WordPress on AWS?

In this tutorial you will learn how to migrate a WordPress website to Amazon’s AWS cloud platform using the Bitnami version of WordPress on AWS.

This tutorial covers all the components necessary to migrate a WordPress website to Amazon AWS, including how to install WordPress on AWS EC2, how to configure your domain name on AWS Route 53, and how to transfer an exact copy of your existing WordPress website to AWS.

Running WordPress in a virtual machine on Amazon’s AWS Cloud Platform allows you to harness the full power of the cloud, and take your WordPress website to the next level.

Is AWS right for you?

If all you’re looking to do is host a simple WordPress website, then AWS is not the best option for you; managed hosting providers are cheaper and easier to use. There are even managed cloud hosting providers such as Bluehost Cloud (view tutorial).

The main reason why you should host WordPress on AWS is because you’re developing a website that you predict will grow in size and complexity over time, and you require a platform built with the infrastructure that your website will require as it grows.

Before getting started with this tutorial on how to migrate WordPress to AWS, you must first create a free AWS account.

There are 3 parts in this tutorial:

PART 1: Deploy WordPress Installation

The first step in this tutorial to migrate WordPress to AWS is to install WordPress on an AWS EC2 virtual machine using a WordPress stack configured by Bitnami.

By default, WordPress is built on a software “stack” consisting of WordPress, Linux, Apache, MySQL, and PHP – meaning that you need to install each of these components to your AWS EC2 virtual machine in order to run WordPress.

Sounds time consuming, right?

The good news is that companies such as Bitnami have already configured and bundled these “stacks” for you. All you need to do is install them to your EC2 virtual Machine.

So let’s get started.

1. Launch an EC2 Instance

migrate wordpress to aws
After you’ve created an Amazon Web Services account, click the Services link at the top of the page, then click the EC2 link under the compute column.
migrate wordpress to aws
From your EC2 dashboard, click on the Launch Instance button to deploy a new EC2 instance. An “Instance” is just a fancy word to describe the Virtual Machine that will be running your WordPress installation.
migrate wordpress to aws
Now that your EC2 instance has been deployed, the next step is to install WordPress. To to this, navigate to AWS Marketplace in the left sidebar column, then search for WordPress and select WordPress Certified by Bitnami.
migrate wordpress to aws
Click the Continue button after you’ve looked over the Bitnami WordPress details page.

2. Choose Instance Type

migrate wordpress to aws
On the next page, select the instance (virtual machine) hardware that you want to run your WordPress installation. Choose the free t2.micro machine.

3. Configure Instance Details

migrate wordpress to aws
On the Configure Instance Details page, choose the Auto-assign Public IP option, and leave the other options unchanged.

4. Review Instance Details

install wordpress on aws
Next, click the Launch button at the bottom of the Instance Details page.

5. Generate SSH Key

install wordpress on aws
Next, a popup window will appear. Create a new SSH key pair as instructed in the popup window. Make sure to download the key pair and save it in a safe place. Next, click the Launch Instances button at the bottom of the popup window.

6. Obtain WordPress Credentials

install wordpress on aws
Congratulations! You’ve just launched a new WordPress installation. However, in order to login to your new WordPress installation, you will first have to obtain your WordPress login credentials. To do this, first click the Services link at the top of the Launch Status page.
install wordpress on aws
Under the Compute column, click on the EC2 link.
install wordpress on aws
Next, click on the Instances link in the left-sidebar column.
install wordpress on aws
On your Instances page, click on the Actions button, then navigate down to Instance Settings then click on Get System Log.
install wordpress on aws
Use the sidebar at the right side of the page to navigate towards the bottom of the instance log. Locate and copy your Bitnami application password.

7. Copy External IP Address

install wordpress on aws
After copying your WordPress password, exit out of the instance log and use the bottom scroll bar to locate and copy your Public IP address.

8. Login to WordPress

install wordpress on aws
In a new browser window, paste the Public IP address followed by wp-admin – this willl take you to the WordPress login page. Enter user as the username, and paste the password that you copied from the previous step into the password field.
install wordpress on aws
That’s it! You’ve successfully logged in to WordPress!

PART 2: Transfer Domain Name

Great job! You’ve just installed WordPress on an AWS EC2 virtual machine!

The next step in this tutorial to migrate WordPress to AWS is to transfer your domain name to AWS so that it links to your website.

Taking the time to properly configure a domain name for your website is an easy way to prevent search engine indexing issues from occurring.

By default, your public IP address will be used as the domain for your website. However, using a public IP address as your primary domain is bad for your website’s SEO.

In this next section you will learn how assign a custom domain name such as yourwebsite.com to your AWS EC2 instance.

NOTE: Before getting started with this section of the tutorial, you may want to first export a copy of your existing WordPress website, as demonstrated in part 3 (step 2).

1. Copy Virtual Machine IP

transfer domain to aws
Login to your Amazon Web Services (AWS) account, and click on the Services link at the top of the page.
install wordpress on aws
Under the Compute column, click on the EC2 link.
install wordpress on aws
Next, click on the Instances link in the left-sidebar column.
install wordpress on aws
Use the bottom scrollbar to navigate right to copy your instance’s Public IP address.

2. Create a Hosted Zone

transfer domain to aws
In the URL bar of a new browser window, navigate to Route 53 by entering the following URL: https://console.aws.amazon.com/route53/home
transfer domain to aws
Click the Get started now button on the Route 53 homepage.
transfer domain to aws
Next, click the Create Hosted Zone button at the top of the page.
transfer domain to aws
On the Create Hosted Zone page, enter your domain name in the Domain Name field, then click the Create button to create a new hosted zone.

3. Add “A” Record

transfer domain to aws
At the top of the Hosted Zones page, click on the Create Record Set button.
transfer domain to aws
In the Type field, select A Record, and paste your public IP that you copied in one of the previous steps into the Value field, then click the Create button at the bottom of the page.

4. Add “CNAME” Record

transfer domain to aws
Next, click the Create Record Set button at the top of the page to create another Record.
transfer domain to aws
Enter www in the Name field, and select CNAME as the record type. In the Value field, enter your domain, then click on the Create button.

5. Edit Domain Name Servers

transfer domain to aws
On your Hosted Zones homepage, copy the nameservers in NS section of the page.
transfer domain to aws
Head over to your Domain Name registrar (Name Cheap is used in this example) and assign the nameservers that you just copied to your domain.

6. Test Settings

transfer domain to aws
After a few minutes, try accessing your site by entering your domain name into the URL bar. If everything is configured properly, you will see your WordPress homepage.

How to Include WWW. Prefix

By default, your domain will show without the www. prefix.

If you would rather your domain show up as www.example.com instead of just example.com, then read on for configuration instructions.

NOTE: The instructions below are intended for users running Bitnami’s WordPress stack on AWS. If you’re using a different Apache configuration, remember to substitute the bitnami.conf file with your server’s htaccess equivalent.

In order to add the www. prefix to your domain, you will first need to configure an SSH client to connect to your EC2 instance. To learn how to SSH into your EC2 instance, check out How to SSH into EC2 Instances (AWS).

transfer domain to aws configure www
After you SSH into your EC2 instance by following the instructions in this tutorial, copy and paste the command below to open your server’s configuration file (right-click to paste).
sudo nano /opt/bitnami/apache2/conf/bitnami/bitnami.conf
transfer domain to aws configure www
Now that you’ve opened your server’s configuration file, copy and paste the three lines of code below in the exact same location as shown in the image. Save changes to the file (CTRL + O) then exit (CTRL + X) to the home screen.

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
transfer domain to aws configure www
Now that you’ve opened your server’s configuration file, copy and paste the three lines of code below in the exact same location as shown in the image. Save changes to the file (CTRL + O) then exit (CTRL + X) to the home screen.
sudo /opt/bitnami/ctlscript.sh restart apache

PART 3: Import WordPress Website

Great job! You’ve assigned a custom domain name to your new WordPress installation!

Using a WordPress Migration plugin is a great time saver when transferring a WordPress website between hosting providers.

The next step in this tutorial to migrate WordPress to AWS is to transfer an exact copy of your existing WordPress website to your new WordPress installation on EC2.

In this tutorial, you will use the All-in-One WP Migration Plugin to quickly transfer a copy of our existing WordPress website to our new WordPress installation on AWS EC2.

So let’s get started.

1. Download WP Migration Plugin

migrate wordpress installation all-in-one wordpress migration plugin
From your existing WordPress website (the one you want to transfer to AWS EC2), head over to “Add Plugins” and download the All-in-One WP Migration plugin.

2. Export Website File

migrate wordpress installation export wordpress website to file
Activate the All-in-One WP Migration plugin, and access it by clicking the link in your WordPress sidebar column. From the All-in-One WP Migration dashboard, select Export To > File.

NOTE: The free version of All-in-One WP Migration plugin limits the WordPress upload file size to 512MB. If your WordPress file size is greater than 512MB, check out this tutorial on how to increase the upload size limit to 4GB+.

3. Import Website File

migrate wordpress installation import file
From your new WordPress Website installation, download the All-in-One WP Migration plugin and go to Import From > File. Choose the export file that you downloaded in the previous step.

NOTE: By default, the All-in-One WP Migration plugin only allows a maximum file upload size of 512MB. If you need to increase the maximum file upload size to 10GB+, check out this tutorial.

4. Change Permalink Structure

migrate wordpress installation permalink dashboard
After you’ve successfully imported your WordPress website to Google Cloud, you will need to reset your permalink structure. From your WordPress dashboard go to Settings > Permalinks, and select the permalink structure that you prefer (I recommend post name).

NOTE: After finishing with the WordPress migration, you can uninstall or deactivate the All-in-One WP Migration plugin.

Did it work?

That’s it! You’ve successfully migrated your WordPress website to AWS, including installing WordPress, configuring a custom domain name, and transferring an exact copy of your existing WordPress website to AWS.

If you have general questions or comments about this tutorial, please post them below.

If you benefited from this tutorial, and would like to support my work, please like my Facebook page and subscribe to my YouTube channel.

Thanks,

signature

Leave a Reply

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

Made with by

© 2020 One Page Zen Systems, LLC  
Legal  |  Privacy Policy  |  Affiliate Disclosure  |  Contact  

Join our Mailing List!

Exclusive early access to the latest tutorials

Monthly update with a list of upcoming tutorials

Special access to members-only events and webinars