Migrate WordPress from CPanel to AWS Lightsail

22nd Dec 2018 - Chris Eather

In this guide, I will show you how to move your existing website or blog from a shared hosting account to AWS Lightsail.

Is Lightsail right for me?

Lightsail may be the solution for you if:

  • You require direct host access but don’t want the complexity of installing and managing Apache, PHP and MySQL by yourself
  • You require better performance than your current shared hosting plan is providing without breaking the bank

1. Create your new instance

The first step is to create your Lightsail instance. Select the region you would like to create your instance in and then select WordPress.

Lightsail - Create instance

Create a SSH key pair and ensure you save the .PEM file somewhere safe as you will not be able to redownload it. This .PEM file will be required later to connect to your instance.

Lightsail - SSH

2. Assign Static IP

After your instance has been created select the 'Network' tab and assign a public IP to your virtual machine.

If you do not complete this step, your instance may receive a different public IP address after a reboot.

3. Connect to your instance via SSH

Now that your instance is up and running with a public IP address, you can now connect to it via SSH. In this tutorial, I will be using PuTTY.

The first thing you will need to do is open PuttyGen and select “Load” to open the .PEM file you created earlier. You will then select "Save Private Key" (.PPK) somewhere safe.

Now that you have a PPK file generated you can connect to your new instance. Open a new PuTTY window and configure the following Settings

  • Session > Host Name: <Your Public IP>
  • Connection > SSH > Auth > “Private Key For Authentication” <Your PPK File>
  • Connection > SSH > Tunnels > Source Port: 8888, Destination: click “Add”
  • Connection > Data > Auto login username > “Bitnami”

Save these settings as a preset within PuTTY for future use. Click “Connect” and you will be logged into your instance.

4. Get the default password for new WordPress Instance

Now that you are logged into your instance, you can gather the default password on your new WordPress installation. Run the following command:

cat bitnami_application_password

The output of this command will give you the default password so you can login to your site (http://SERVER-IP/wp-admin) with the username “user”

5. Update wp-config.php

Now that your new environment is up and running, you will want to tell WordPress to use your custom domain. Connect to your site via FTP or WinSCP (SSH) and modify your wp-config.php file which is found under /opt/bitnami/apps/wordpress/htdocs

Edit this config file and replace this…

define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/');
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/');

…with this, remembering to update ‘domain’ to your real domain name.

define('WP_SITEURL', 'http://DOMAIN/');
define('WP_HOME', 'http://DOMAIN/');

After you have done this, you can update your machine’s local host file to point to your new environment if you wish.

6. Add your SSL certificate

Your certificate must be PEM formatted and follow the following naming convention.

  • server.ctr (your certificate)
  • server.key (private key)
  • server-ca.crt (intermediate CA – if applicable)

Copy these files (replace what is there) under /opt/bitnami/apache2/conf. Restart Apache to see if the certificate updated correctly. If the cert and the key don’t match, Apache may fail to start!

7. Migrate your site

At this point, you should have WordPress installation with your domain name and SSL certificate working. You can now migrate your database and content however you choose. For ease, I use the All in One WP Migration plugin, so I simply restore the latest backup file from my live site.

Once you have confirmed that everything is working as it should be you can update your DNS records to point to the new environment and remove the modification you made your local machine’s host file.

About the Author

Chris Eather


Chris joined Data Lync as a Director and shareholder in August 2018 after his business was acquired.

Chris brings experience from a range of sectors including finance, aged care, and professional services organisations.