So I went down the rabbit hole. I was reviewing a websites performance metrics after it was throwing errors due to an unusually high number of visitors joining an live-stream event hosted on one of our websites. In this case, each user had to enter their login information as well as submit a registration form. This meant that the website was sending huge amounts of requests simultaneous to verify information and log the registration details. Well we always install and set up the common optimization plug-ins to make sure that we cache the sites as much as possible, it's not always enough because database queries like these can't be cached.
This got me thinking, even though we are running the website on a powerful web post, have we really configured all of the settings to make sure that the website can access the resources it needs with causing any errors.
After spending hours researching the best settings for WordPress what I came to realize is that most of these settings are not correct for high performance servers and we're really designed for simple shared hosting accounts where the server itself does not have many resources available. As I primarly use AWS for production website I thought the world needed a reference sheet of the setup process to get your improved load times for websites that need to handle large volumes of traffic and respond fast.
Setting up the WordPress site in AWS Lightsail Console
Choosing a plan
Setting up your AWS instance is has a couple options you'll need to choose based on the purpose of the website. First off, you'll want to choose what zone your website should be hosted in geographically. This is a nice feature as a Canadian to be able to host our websites in Canada.
After that you'll have a list of blueprints which will preinstall apps and the OS. In this case you'll want to select WordPress.
Choosing your plan get's a little more complicated. There are a bunch of different server configurations which with different levels of performance. It's tempting to choose the $3.5 USD plan which might be fine for a really simple WordPress website but I personally like to use the $20 plan which has 2vCPUs and lots of ram for most websites. If you're website is expected to take serious load or handle complex processes then you might want to upgrade you installation accordingly. Amazon will allow you to "upgrade" your instance if you find it's not performing fast enough but not go down. There are ways to get around this like doing a WordPress migration but it's a bit of a pain.
Lastly, choose a name for your instance. This is only for you so it doesn't really matter too much what you call it as long as you'll know what it is. Press the Create Instance and then you're on your way.
Assigning a Static IP
You might need to wait a minute or two for the instance to spin up but once it's created you'll see it listed with the status of Running.
To assign a Static IP address, open the options by clicking the title of your new instance and click over to the networking tab.
Click the + Create static IP and this will show you a setup screen which will attach your new static IP address. The only field to fill out is naming your IP address. I recomment using the same name as your instance and add -ip to the end to keep things consistent. In my demo circumstance this would be michaelwood-demo-ip
Creating a DNS Zone
We've got a server with a static IP. Now it's time to connect your domain name so you don't have to hand out business hards with an IP instead of an website URL. Head over to the Lightsail Console Networking tab. Not to be confused with the networking tab within your instance. You should see some buttons that look like the screenshot below.
Enter your domain name. In this case, I'll use thedomainname.ca (yes, I actually registered it) and create the DNS zone.
There are few things you'll need to do in the DNZ zone. The first step is update your domain registrar with the AWS nameservers provided. Secondly, you'll want to create DNS records to point at your static IP as formated below. I also recommend creating another A record with the www subdomain to also point at your instance IP. You may also need to add MX records for your email service or other services. DNS Propogration times can take a while to kick in so you may want to grab lunch after configuring these settings so the internet has time to catch up with the changes.
Connecting using SSH
Let's do a quick test to make sure your DNS settings have propogated before contining. I like DNS Checker which let's you see the propogration across multiple nameservers across the world. You should see the domain name a record matching the IP address for your instances static IP address.
If the DNS has propagated then head over to your AWS Lightsail console and click on the title of the instance. You'll see a button to Connect using SSH.
This should bring up the SSH console which leads us into our next steps to getting WordPress configured.
Removing the Bitnami Banner
If you've visited the new website since it was set up you may have noticed a Bitnami banner at the bottom right of the window. There is an X button to close this but it will reappear every time you visit the site.
To get rid of this banner, we're going to need to run the helper tool by typing in
Press enter on the Remove the Bitnami Banner option and after a couple seconds you should see a Sucess message. Reload the page and that pesky banner is gone.
Set up SSL with Let's Encrypt
Next up, let's enable SSL so visitors will be able to access your website through https. Using the same Bitnami helper, go down to the second option for Set up Let's Encrypt.
The domain list, enter the domain name(s) that you want the encryption to be enabled for with a comma between addresses. This is usually your domain with and without the www. If your only setting up a subdomain like blog.thedomainname.ca then skip the www version.
The next prompt will ask if you would like to redirect http traffic to https. I would recommend turning this on by pressing Y and pressing enter.
You will also have an option to redirect non-www to the www version of your domain. I usually press N.
It will then prompt you for the reverse redirecting traffic from the www to the non-www which I would press Y.
The last step to enabling your Let's Encrypt is agreeing the terms and conditions followed by entering your email address and confirming some more terms.
If you see the success message like the screenshot above then you did everything succesfully.
Finding your login credentials
Ok, we've got WordPress up and running with SSL encryption so it's time to get logged in. The Bitnami installer has automatically created a user and assigned a password which can be found using the SSH terminal.
To see the password, type in
Head over to your WordPress Dashboard by going to thedomainname.ca/wp-admin using your domain name of course.
You should now be in!
Important changes to wp-config.php
The default configuration of your WordPress site uses a relative site URL which can cause search engine problems. To fix this we'll need to update the wp-config.php file.
From your SSH console run the command,
This will open the nano editor of the wp-config file which you'll want to scroll down to where it says define('WP_SITEURL', '')
Change both the WP_SITEURL and WP_HOME to reflect your URL with the https.
Save the changes and you're done. WordPress will now force all traffic to use the https protocol and the correct domain name format.
Adjusting the PHP.ini Settings
We're almost done getting everything configured. Bare with me to adjust these last couple settings to improve the performance of your WordPress site.
Use the SSH console and enter
Increase the WordPress Maximum File Upload Size on Lightsail
We always try to keep files small on the web but sometimes you need to upload a big plugin, PDF document, or video file. The default value for AWS Lightsail instances have a maximum upload size of 40mb. I find this limit on the small end and often increase the maximum size to 128mb. There is a risk if you have any user forms that your server may get filled up with big files but this can also be managed separately.
Editing the php.ini file you'll want to adjust the following values.
upload_max_filesize = 128M
post_max_size = 128M
max_execution_time = 300
Increase WordPress Memory Limit on Lightsail
Modern websites need access to more memory, especially WordPress websites using visual builders and feature-rich plugins. I recommend bringing your maximum memory limit to 512mb for most purposes but this can also be impacted with the total RAM available on the server instance. The linux operating system on your AWS Lightsail instance will also need some memory so if you've choosen an instance that only has 512mb then you may want to bring this down to reduce the change of errors.
memory_limit = 512M
If you're still reading at this point, kudos! It may seem like a lot of steps to configure a simple WordPress website but with the low cost and incredible scalability of AWS's Lightsail service it's hard to choose any other web host. I've had a lot of success running our sites this way and I hope this guide has helped you launch your first site on the AWS platform.