WordPress site on AWS Lightsail

·

17 min read

WordPress site on AWS Lightsail

I’ve never been a huge fan of WordPress purely because when you want a quick one page website, I find the admin dashboard a bit complex and all the good stuff really needs to be bought. So for a quick one-pager startup like site, I think something like Wix works better.

But this time around I needed a more complex site and since I’ve been recently dabbling in AWS, I thought this would be a good opportunity to try out Lightsail .

What will you learn in this tutorial…

You will learn to launch a Wordpress site on AWS’ Lightsail resource. I chose Lightsail over EC2 since it is a managed system focused on Wordpress. It also has a pre-set image for Wordpress so it’s pretty quick to launch.

I have also added some tidbits on using Wordpress — things that I found useful as I was a complete newbie to it. Unfortunately, I can’t do a detailed tutorial on this aspect because each theme is so different and uses different plugins so it’s hard to have a generic tutorial.

You will also learn to point your domain to this Wordpress site, set up an SSL certificate for it, add a Sendy signup form (because of my Sendy tutorial ), connecting to Google Analytics and so on.

My disclaimer: I’m not associated with any of the companies referenced in this tutorial so my opinions are honest here.

What do you need

  • You will need an AWS account. This takes some time so start well ahead.
  • Wordpress offers a lot of free website templates but if you want something specific and advanced, you will need to buy one.
  • A domain with access to the DNS settings.
  • A relatively good sense of designing as a website is all about that.
  • Some technical abilities. Even though Wordpress has a good CMS platform which doesn’t require much technical expertise. But this is good so far as you are just putting up some blog posts or simple edits. For creating the website, a tech background will be useful.

Steps

  1. Create an AWS Lightsail instance: Connect to instance via SSH
  2. Install a theme
  3. Editing the website: Posts vs Pages, Unpublishing a page, Change your homepage to a non-blog page, Change author of a post, Widgets, Menus, Plugins
  4. Pointing site to custom domain
  5. Adding SSL certificate

Optional

  1. Backing up website
  2. Connecting to Google Analytics
  3. Set up SMTP
  4. Add Sendy subscribe form to the site

Create an AWS Lightsail instance

  1. Login to your AWS account.
  2. Under Services, look for Lightsail.
  3. Click Create Instance.
  4. If you have already been using AWS for other services, it will automatically select your most used availability zone under Instance location. If you would like to change it, do so now.
  5. Under Pick your instance image: Select a platform: Linux/Unix, Select a blueprint: Apps + OS, select Wordpress
  6. The free tier only offers one month free for the lowest instance plan which at the time of this tutorial has the following specs:
    Memory: 512 MB
    Processing: 1 vCPU
    Storage: 20 GB SSD
    Transfer: 512 GB
    
    I found this sufficient for a basic site (the highest CPU utilisation I had in the last 2 weeks was 2.98%) but you can change it in the future — https://aws.amazon.com/premiumsupport/knowledge-center/change-lightsail-plan/
  7. Identify your instance a.k.a. give it a name.
  8. Click Create Instance.
  9. You will be taken to the Lightsail dashboard , on the Instances tab where you should see your newly created instance. It should say Pending while the instance is being created. Once it’s ready the status will say Running.

Connect to instance via SSH

When the instance is first launched, you will need to connect via SSH to your instance to get the Wordpress admin login and password.

  1. Go to your Lightsail dashboard .
  2. Click on your newly created instance.
  3. Here you will see some general information about your instance,
    Status: is it running or not?
    Public IP: this is where your site is currently hosted
    Connect securely using your browser
    
  4. Test whether your Wordpress site has been launched by entering your in your browser. This should show you a default website created by Wordpress.
  5. Coming back to your Lightsail instance’s dashboard, click on Connect using SSH.
  6. This will open up a new window which looks like a terminal and log you into the instance automatically.
  7. Enter the following in the terminal: cat bitnami_application_password
  8. Your password will be displayed. Copy it. Close the SSH connection.
  9. Go to the Wordpress admin page — /wp-login.php
  10. The username is always user by default. And enter the password you just retrieved.
  11. This is where you can edit the website.
  12. Before continuing with the next steps, check your Dashboard for any plugin updates. Make sure everything is up to date, before you start editing.

Install a theme

Finding an appropriate theme is half the work of building the website. Your WP installation comes pre-installed with some of their free and most popular themes like Twenty Twenty. But you can browse for more as well.

  • On your Wordpress admin dashboard, under Appearance -> Themes -> Add New, you can search and install any theme.
  • Themes can also be searched here — https://wordpress.org/themes/
  • If your site is very specific, for example, an art portfolio or startup or financial firm, I would recommend doing a google search for themes focused on your area.
  • A paid theme is not a bad idea because most of them come with 6 months support (especially if your new to this like me) and they provide dummy data and pages which can easily be edited.
  • This is a good site to buy some themes — https://themeforest.net/

If you’re buying a theme…

  1. Once you buy a theme, you will be asked to download a package with documentation and a zip folder containing the relevant theme files.
  2. Go to your WP admin dashboard.
  3. Go to Appearance -> Themes -> Add New -> Upload Theme
  4. Click Choose file and upload the theme’s zip file.
  5. Click Install now.
  6. Most themes provide their own documentation as to how to proceed after this.

Editing the website

Each theme is so different in its setup that it’s pointless for me to cover step by step details of how to edit a website. So I’ve covered some generic items here that helped me understand WP better. All navigation for editing your WP site will happen on the WP dashboard (/wp-login.php) so for this section I am assuming this as the starting point.

Posts Vs Pages

This is the crux of WP. Initially, WP was created as a blog focused platform which is why by default, the first time you launch WP, the placeholder website is a blog site and has the blog as its homepage.

Posts are each blog articles that you write. They get automatically added to your blog page.

Pages are your website pages, typically shown in the menu on top.

If you are not creating a blog, you can select a theme that is focused on a typical regular website. Although, they do provide a blog page, it is not your homepage by default. Nowadays most company sites do have a blog section so I’m happy to keep it but if you must absolutely remove it, you can make the page private (which technically unpublishes it). Although, first you must re-assign the home page to some thing other than the blog. I have described the procedure few sections below.

Unpublishing a page

  1. Go to Pages -> All Pages
  2. Find the page you want to unpublish. If you want to remove the blog page, it is typically annotated with Posts Page. For example, if your blog page is called Blog then on the list of Pages, it will be called Blog — Posts Page.
  3. Hover over it and select Quick Edit.
  4. Check Private.
  5. Click Save. This should annotate your page title with — Private.

Change your homepage to a non-blog page

If you have decided to keep a blog page but don’t want it as the homepage, then you can follow the steps below. Assuming you have made a homepage already.

  1. Go to Settings -> Reading
  2. Under Your homepage displays, select A static page and select your homepage and posts page accordingly.

    Note: for more details — https://www.wpbeginner.com/wp-tutorials/how-to-create-a-separate-page-for-blog-posts-in-wordpress/

Change author of a post

When you publish a post, you will notice that it says Published by user on the actual post on the website. This doesn’t look great if you are posting for a company and there is no way to disable showing the author of the post. So a neat little trick is to create a new user on WP called something like Editor or Author or Team Member or simply your company name to publish articles.

  1. Go to Users -> Add New
  2. Create a user with the role Author

This user can only write/edit posts and not change anything else on the website. The nice thing is that when they publish, you will see a nice generic name like Editor.

Widgets

Most themes have allocated certain areas on your page for which widgets can be added. For example, footer, sidebar, header, toolbars etc. Under Appearance -> Widgets you will be able to edit these sections of your page.

Some widget examples are

  • Search bar
  • RSS
  • Recent Posts
  • Calendar
  • Image
  • or simply Custom HTML to add your own code.

This represents the main menu of your website. Your theme decides the placement and design of the menu but the actual items on the menu are upto you.

Go to Appearance -> Menus to edit what pages you want to show in your menu.

You can also create multiple different menus. This is useful when you want to show different menus for different locations. For example, the theme that I bought has a Primary Menu and a Mobile Menu. So I can show different types of menus based on the device. If this is important to you (as I found it important to me), look out for it when buying a theme.

Plugins

WP’s usefulness comes from its abilities to have plugins for all aspects of your website. You can get a plugin to create a contact form or a sidebar navigation menu or fancy headers for the page. There is a plugin for pretty much everything. You can search for plugins here — https://wordpress.org/plugins/

Point site to custom domain

Once you have the website ready or reasonably enough to make it public, we need to point a custom domain to it; you can’t share just the Lightsail’s public IP address.

  1. Go to your Lightsail dashboard .
  2. Click on your WordPress instance.
  3. Click on the Networking tab.
  4. Click Create static IP.
  5. It will ask you to attach it to an instance. Select your WordPress instance. This is important. If you do not attach an instance to your static IP, you will be charged for it.
  6. Give it an appropriate name.
  7. Click Create.
  8. Give it a few minutes for the site to get redirected to the new IP address.
  9. In the meantime, head on over to your domain’s DNS settings.
  10. If you don’t already have an A record for your domain, then add one:
    Record Type: A
    Record Name: [Leave blank if this is the root domain otherwise enter subdomain]
    IP: <static-lightsail-ip>
    
  11. DNS records can take time to update so do check after a few hours. A quick check on a terminal can be done as so host <your-domain>
  12. Important: For the following steps, you must wait for the domain to fully propagate. So take a breather here before continuing.
  13. Also your Wordpress dashboard will now be accessed via — /wp-login

Add SSL Certificate

Now that your domain points to your new WP site, let’s continue.

Since this Wordpress site is built using Bitnami on AWS Lightsail, Bitnami provides a nifty tool to set up free SSL certificates using Let’s Encrypt.

  1. Go to your AWS Lightsail dashboard.
  2. Click on the terminal icon on your WP instance to login into it via SSH.
  3. Once your logged in, run the certificate tool — sudo /opt/bitnami/bncert-tool. It might ask you to update it before running it; just follow the onscreen instructions.
  4. Once the tool is updated, run it again. First, it will ask you to enter the domain you wish to certify:
    example.com
    www.example.com
    
  5. Then you will go through a series of questions on redirections. Typically, you redirect a example.com site to example.com
  6. Next, it will tell you the series of steps it’s going to perform. One brilliant feature of this tool is that it sets up auto-renew for your SSL certificates since Let’s encrypt only allows for 3 months at a time.
  7. After this, you will be asked to enter your contact details and agree to the agreement.
  8. And that’s all! Check your website; it should have a valid certificate.

Optional Steps

As the name suggest these steps are optional and there are multiple ways of doing them. I have written about the ones that I have used.

Backing up the website

There are many plugins that can help you with backing up your website but I used All-in-On WP Migration because it was a quick copy of the whole website with the theme and everything. No technical knowledge was required and even if you do come from a tech background, I just felt it wasn’t worth the hassle to do a WP migration manually.

It’s pretty straightforward. You install the plugin on your WP Admin dashboard (/wp-login) under Plugins. It will most likely already be there and you simply need to activate it.

You should see All-in-One WP Migration in the menu on your Wordpress admin dashboard. Click it and go to Export. Then simply click the Export to drop down and select how you want to save a copy. It will also keep a copy on your site but if you lose the site then you won’t have access to it, so definitely make an offline copy.

Connecting to Google Analytics

GA gives you great insights on how well you’re website is doing. How many hits does it get, the demographics etc.

  1. Sign up on Google Analytics using your GSuite account.
  2. Click Start Measuring.
  3. Now it will ask you to create an ‘account’ for the website. This is not a new GSuite account, it’s like a project. Give it an appropriate name like Company Website or something.
  4. Click Next.
  5. Select Web.
  6. Click Next.
  7. Enter the information for property setup and click Create.
  8. Accept the T&Cs, and you have set up Google Analytics. Now we need to connect it to our website.
  9. You will be taken to a page which has the Tracking ID and code.
  10. Copy the tracking code under Global Site Tag.
  11. Head on over to your WP admin dashboard and install the following plugin — Insert Headers and Footers .
  12. Once installed, activate it.
  13. Once it’s activated, you should see it in Settings -> Insert Headers and Footers. Select it.
  14. Paste the tracking code you copied from the GA, into the Header.
  15. Click Save.

The website is linked to your GA account.

Note: Alternatively, you can also use the MonsterInsights plugin to connect GA to your Wordpress dashboard.

Set up SMTP

Once again, there are multiple ways and options to set up SMTP on your site. SMTP is important if you are going to have contact forms or some such that require emails to be sent from your site. It’s also important to set the emails for your user accounts on the Wordpress admin dashboard. If you go to your profile (top right Hi user) and select Edit Profile, it will currently have your email address as . All of these things require an SMTP setup.

Since I was already set up on AWS SES , I decided to use this to set up SMTP. Plus it’s really cheap compared to other popular mail servers. Although, I should add in my experience of using AWS SES, a good percentage of the emails would go to the client’s spam folder when you first start using it. Even after setting up all the verifications. From what I understand, other mail servers are a little more efficient in this case. But my client base was relatively small, so hence it was an acceptable compromise.

Anyways, I had already set up the SES services in one of my other tutorials so I’m just going to adapt that here. But for a longer explanation, you can check out that tutorial.

You have two options: either to verify a domain or an email address. It’s good to verify a domain because that gives better security for the email sending and thereby lesser chances of spam.

  1. Login to your AWS console and navigate to SES.
  2. Click Domains on the left menu.
  3. Click Verify New Domain.
  4. Enter your domain— <mydomain>.com. Ideally this domain should match your website domain.
  5. Check Generate DKIM Settings.
  6. Open your domain’s control panel where you can set the DNS records.
  7. There should be two types of records to add: Domain Verification Record (TXT) and aws.amazon.com (CNAME). Add them to your DNS settings.

    Note: If your domain already has email associated with like Gmail, do not add the Email Receiving Record.

  8. Check your email associated with your AWS account and shortly, you should receive confirmations of the domain being verified.
  9. You can do the same steps for adding an Email Address.
  10. Verifying a domain still only allows you to send a limited number of emails and only to the emails in the same domain. This is the sandbox environment. See note below on how to get out of it.

Note: When you have tested enough and are ready to increase your limits on SES and get out of the sandbox environment, you need to make a request to AWS. Find details here — https://docs.aws.amazon.com/ses/latest/DeveloperGuide/manage-sending-quotas-request-increase.html

Once the domains/email addresses are verified, go back to your AWS SES dashboard.

  1. Select SMTP Settings on the left-hand side menu.
  2. You will see the configuration for your SMTP: Server Name/Hostname, Port, TLS. You will need these when configuring your Wordpress site. But first, click on Create My SMTP Credentials.
  3. Follow the on-screen instructions and give the user an appropriate name to identify it with. Like user-website. So you know that these credentials are being used on your website.
  4. The next page, will give you an auto generated username and password. Save these. This is the only time you will be allowed to download/save the credentials.

Now we go over to your Wordpress admin dashboard to set it all up.

  1. On your WP dashboard, select WP Mail SMTP on the left-hand side menu. If you don’t see it, then it’s possible the plugin is not activated or has not even been installed. Go to Plugins, to activate/install it. Here is the link to the plugin info — https://wordpress.org/plugins/wp-mail-smtp/
  2. Enter the email that you verified or at least an email from the domain you verified. And the rest of the details like Name.
  3. Under Mailer, select Other SMTP.
  4. Under SMTP Host, enter the Server Name from your AWS SES.
  5. Encryption: TLS
  6. SMTP Port should be automatically filled to 587 or any of the three provided on the AWS SMTP Settings page.
  7. Authentication must be on.
  8. And now enter the SMTP Username and Password that you downloaded from AWS SES.
  9. Click Save Settings.
  10. Scroll up, and click Email Test.
  11. Check your inbox to see whether you got the email and from the correct From email and name that you entered in the settings.

Add Sendy subscribe form to the site

If you have also followed my tutorial on Setting up a bulk mail server using AWS and Sendy , then you can add Sendy subscribe forms to your site.

  1. Go to your sendy website.
  2. Go to View All Lists -> select the list you want to create a subscribe form for.
  3. On the top menu, you will see an option called Subscribe Form, click it and copy the HTML code. I had wanted to embed it on the site so users can directly sign up there without being redirected to another sign up page.
  4. Go to your Wordpress admin dashboard. Friendly reminder: <your-domain>.com/wp-login
  5. There are numerous places you can add your form. If you simply want to add it somewhere on your page, go to Pages and find a suitable location for it and add it as custom HTML, alternatively, you can also add it somewhere like a footer…
  6. Go to Appearance -> Widgets.
  7. Based on your theme, there will be ‘areas’ or locations provided — header, first footer, sidebar. These are different locations of your website which are generally consistent on every page such as a footer.
  8. Drop a Custom HTML widget on any of the ‘areas’ provided by your theme and enter the HTML you copied from Sendy.
  9. Refresh your site and make sure it is working correctly.

And that brings us to the end of another long tutorial. Hope this was useful. Unfortunately, with Wordpress there are many combinations and permutations of doing things. I’ve covered what I felt was the most straightforward and useful but you might have had a different experience, which I’m always happy to hear about in your comments below.

Thank you all for the support on all my blog articles. I hope this one finds you well. As always, please post any feedback/questions/edits/suggestions. You can also tweet out to me — https://twitter.com/neha_m25