Raddy Website Design & Development Tutorials

Step-by-Step Guide to Migrate Your WordPress Site to AWS Lightsail

By Raddy in Other / WordPress ·

Today we are going to look at how to create & migrate a WordPress website on AWS Lightsail. You could either choose to watch the full video tutorial below, or read the article.

Watch the full video

Table Of Contents

Create AWS Lightsail instance

First of all, you need to create an AWS account. Once you have made your account navigate to the AWS Lightsail page.

Create your first instance by clicking the orange button “Create Instance”.

Creating new instance

The first step you need to do is to choose your location. You can either choose the one closest to you or the one that most of your visitors come from. It’s really up to you!

The second step is to choose Linux/Unix and then go for WordPress.

Scrolling down you will get to the point where you can Enable Automatic Snapshots (that might be a good idea) and you need to choose your instance plan. AWS Lightsail is fairly flexible and you can always upgrade or downgrade if you wish.

I am going to choose the first option which is only $3.5 USD and also the first month is free (at this moment).

Identify your instance and then click the big orange button at the bottom “Create Instance”.

Alright, we are done here. Let’s move on.

Accessing your website

As soon as you set up your instance you should be able to view your newly created WordPress website.

Click on your instance name:

Now find the Static IP on the right side of the screen:

You can put that Static IP in your browser address and access your website. Sometimes it takes a few seconds, so be patient.

Admin Dashboard Username and Password

To find out the password credentials we need to connect to our instance via the SSH terminal. To save time, we can use AWS’s handy browser SSH terminal.

Click on the “Connect using SSH” button.

AWS IP

The terminal should pop up and look something like this:

Now type the following command:

cat bitnami_application_password

Your password should be displayed in the middle like in the image below:

Now you can use:

Usernameuser
Passwordt0DIXmNs30 – this is obviously an example.

To access your admin panel you can type your [youripaddress]/wp-admin

If you are stuck you can always read the official AWS documents.

Point a Domain in Amazon Lightsail

First of all, let’s Create a static IP address just in case our Public IP changes.

Go under the Networking TAB and click + Create static IP. Follow the instructions and save.

We can now use the new Static IP to add to our DNS address records aka (A Record). Note that sometimes DNS records could take up to 24 hours to propagate. You can always check how the propagation is going by using a website such as Whatsmydns.net.

Update Domain name DNS records

This could be slightly different for everybody. Usually, your domain name provider would have instructions on how to do this. Our main objective is to find our DNS settings. In 123-Reg they are under Advanced domain settings and then Manage DNS.

Click on Advanced DNS and update your A records with your new Static IP that we just created above.

That’s it, our domain name is now pointing to AWS. You can use the as Whatsmydns.net. tool to check if your record has been updated. It could take some time so be patient.

Inpatient? Once the records start to propagate, but your web address isn’t working yet, you can try to flush your DNS.

Now that we have the domain name set up, it’s probably a good time to add our FREE Bitnami SSL certificate.

Setup FREE SSL (https) certificate Bitnami HTTPS Configuration Tool

Adding a Free SSL should be a fairly easy process. Go back to your instance and click “Connect using SSH” just like we did before. This time type the following command:

sudo /opt/bitnami/bncert-tool

It might ask you to update the bncert tool. Just press ENTER – Yes and run the same script again:

sudo /opt/bitnami/bncert-tool

The terminal will now lead you through the process of setting everything up.

Your newly installed SSL Cert should automatically update, but it’s always good to check from time to time to see if the automatic update works.

Access PHPMyAdmin in Lightsail

This is the shitty part. I wish that there was a better way of doing this and if you know of one, please comment below and I will update the article.

Ideally, I would want to access the PHPMyAdmin database using a tool like HeidiSQL or MySQL Workbench, but the solutions out there that I was able to find did not seem very safe to do. This is probably the safest way of accessing your database.

Download PuTTY+ PuttyGen. Usually, when you download PuTTY, PuttyGen is automatically installed. If not find it and install that too.

PuTTY user interface looks like this. It’s a gorgeous tool!

Download PEM key

Navigate to Amazon Lightsail, click on the Connect Tab and at the bottom, there will be a link to the Account page.

Lightsail Account Page

Once you are at the Account page, navigate to the tab SSH keys and from there you will see the download button. Download your PEM key.

PuTTY Key Generator

We now need to use the PEM key that we just downloaded to generate a public/private key pair. To do this, load PuTTY Key Generator, click Load and select the PEM key that we just downloaded. Once you do that, click on Generate and Save the private key. Save the file somewhere for later use.

PuTTY key Generator

PuTTY Configuration

Open the PuTTY Configuration tool and let’s start with the session Category. Click on Session, add your Host Name (or IP address) and set the port to 22. Make sure that you name your session under Saved Sessions and click save so you don’t have to re-configure the settings later on.

PuTTY Configuration

Under Connection -> SSH -> Auth, you can now load the Private Key that we generated earlier with the Key Generator Tool.

PuTTY Configuration Auth

Next, click on Tunnels and set the Source port to 8888 and the destination to localhost. Then Click Add.

PuTTY Configuration Tunnels

Now go back to Connections and click on Data. Fill Auto-login username to bitnami (that’s usually the default name).

PuTTY Data

The last thing that you want to do is go back to Sessions and Save your session. This is important as you don’t want to redo the setting every time.

PuTTY Save Session

Hopefully, at this point, you should be able to click open and connect to your server. If everything went well, you should get a similar command line like this:

SSH Tunnel

We are sailing!

The last step is to go back to your browser and navigate to localhost:8888/phpmyadmin

Hopefully, you should see the PhpMyAdmin page and then you can log in. To get the password, go back to the AWS Lightsail console and do:

cat bitnami_application_password

The username is usually set to: root

You can now import & export database if you wish to.

Connecting via FTP – FilleZilla

Before we do anything here, you need to first have your PEM key downloaded and also you need a tool like FileZilla. Let’s start with downloading the PEM Key.

Download PEM key

Navigate to Amazon Lightsail, click on the Connect Tab and at the bottom, there will be a link to the Account page.

Now that we have the PEM key, open Filezilla, and click Edit -> Settings. Go to the SFTP page and add your key file. Once you do that, press OK.

In FileZilla, go to File -> Site Manager and create a New site. Select SFTP, add your hostname which you can find from AWS Lightsail and add your password.

AWS Lightsail Connect to FTP

If you don’t know your password, you can go back to AWS Lightsail, connect using SSH and type the following command:

cat bitnami_application_password

That’s it. Press Connect and hopefully, at this point, you should be able to access your WordPress files.

Migrating your website

Migrating your website is a matter of importing your database in AWS Lightsail, swapping the WordPress files via FilleZila and just making sure that the settings in your WordPress wp-config.php file are correct. That’s pretty much it.

Folders:

Approach A: Bitnami installations using system packages

  • All files in /opt/bitnami/wordpress are owned by the bitnami system user and the daemon group. This helps to avoid issues when uploading files to the stack.
  • All subfolders in /opt/bitnami/wordpress have 775 using UNIX permissions notation, which means the following:
    • Read, write, and execute: bitnami user and daemon group.
    • Read and execute: rest of system users.
  • All files in /opt/bitnami/wordpress except wp-config.php have 664 using UNIX permission notation, which means:
    • Read and write: bitnami user and daemon group.
    • Read: rest of system users.
  • The wp-config.php file contains sensitive information, and for that reason it has more restrictive permissions. The file has a value of 640, which means the following:
    • Read and write: bitnami user.
    • Read: daemon group.
    • No access: rest of system users.
  • Uploaded files in /opt/bitnami/wordpress/wp-content/uploads using the WordPress media library manager are owned by the daemon user and the daemon group.
  • Installed plugins in /opt/bitnami/wordpress/wp-content/plugins using the WordPress plugin manager are owned by the daemon user and daemon group.

Approach B: Self-contained Bitnami installations

  • All files in /opt/bitnami/apps/wordpress/htdocs/ are owned by the bitnami system user and the daemon group. This helps to avoid issues when uploading files to the stack.
  • All subfolders in /opt/bitnami/apps/wordpress/htdocs/ have 775 using UNIX permissions notation, which means the following:
    • Read, write, and execute: bitnami user and daemon group.
    • Read and execute: rest of system users.
  • All files in /opt/bitnami/apps/wordpress/htdocs/ except wp-config.php have 664 using UNIX permission notation, which means:
    • Read and write: bitnami user and daemon group.
    • Read: rest of system users.
  • The wp-config.php file contains sensitive information, and for that reason it has more restrictive permissions. The file has a value of 640, which means the following:
    • Read and write: bitnami user.
    • Read: daemon group.
    • No access: rest of system users.
  • Uploaded files in /opt/bitnami/apps/wordpress/htdocs/wp-content/uploads using the WordPress media library manager are owned by the daemon user and the daemon group.
  • Installed plugins in /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins using the WordPress plugin manager are owned by the daemon user and daemon group.

Source: https://docs.bitnami.com/aws/how-to/troubleshoot-wordpress-issues/

File Permissions

If you are having problems with your folder and file permissions please look at the article here.

That should be everything. Thank you for watching the video or reading the article!

Thank you for reading this article. Please consider subscribing to my YouTube Channel.

  1. Bukunmi says:

    Hello Raddy,

    Thanks for this tutorial and it is quite useful and helpful. I was going through this tutorial recently and noticed amazon hightail has changed their structure and a lot of permission issues while trying to migrate the site from my current hosting service. Please can you update this tutorial to show the most recent amazon structure.That will be very helpful.

    1. Raddy says:

      Hey Bukunmi,

      I updated the new structure a while back. It’s under the heading “Folders”. The video is not possible to update unless I edit it and re-upload. I’ve just added a comment under the video so people know.

      One thing that you can do is to create a new instance and install fresh WordPress. Then upload your database and files. I think that should work as the permissions would be set and you won’t have to do much. I hope this helps

      1. Bukunmi says:

        Thanks so much for your response. I did see the tutorial heading under Folders and was able to use the information there, as well as the information in the link you shared concerning fixing permission issues.
        Looks like lightsail structure keeps changing, what was in the tutorial is /opt/bitnami/apps/wordpress/htdocs/, and they no longer set the apps folder by default.There are lots of issues using their wordpress system packages. I had to switch to a lamp stack and then use the htdoc folder to upload my files and that worked for me. Thanks so much for your help though I really appreciate, and the tutorial went a long way getting me started with lightsail and wordpress.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.