Deploying a extremely out there WordPress website on Amazon Lightsail, Half 1: Implementing a extremely out there Lightsail database with WordPress

This submit is contributed by Mike Coleman | Developer Advocate for Lightsail | Twitter: @mikegcoleman

This submit walks you thru what to think about when architecting a scalable, redundant WordPress website. It discusses how WordPress shops such parts as person accounts, posts, settings, media, and themes, and configure WordPress to work with a standalone database.

This walkthrough deploys a WordPress website on Amazon Lightsail. Lightsail is the simplest approach to get began on AWS, and it is likely to be the simplest (and least costly) approach to get began on WordPress. You may launch a brand new WordPress website in a number of clicks with one in all Lightsail’s blueprints, for a number of {dollars} a month. This provides you a single Lightsail occasion to host your WordPress website that’s excellent for a small private weblog.

Nevertheless, you could want a extra resilient website able to scaling to fulfill elevated demand and architected to offer a level of redundancy. In the event you’re a novice cloud person, the concept of organising a extremely out there WordPress implementation may appear daunting. However with Lightsail and different AWS companies, it doesn’t have to be.

Subsequent posts on this sequence cowl managing media recordsdata, utilizing CloudFront to extend website safety and efficiency, and scaling the WordPress front-end with a Lightsail load balancer. For reference, listed below are these blogs:

  1. Utilizing Amazon S3 with WordPress to securely ship media recordsdata
  2. Growing safety and efficiency utilizing Amazon CloudFront
  3. Growing efficiency and scalability with a Lightsail load balancer

What’s underneath the hood?

Although you’re a WordPress person, you could not have thought of how WordPress is constructed. Nevertheless, when you’re shifting into managing your WordPress website, it’s important to know what’s underneath the hood. As a content material administration system (CMS), WordPress supplies a number of performance; this submit focuses on a number of the extra important options within the context of how they relate to architecting your extremely out there WordPress website.

WordPress manages quite a lot of totally different information. There are person accounts, posts, media (similar to pictures and movies), themes (code that customizes the appear and feel of a given WordPress website), plugins (code that provides extra performance to your website), and configuration settings.

The place WordPress shops your information varies relying on the kind of information. On the most simple stage, WordPress is a PHP utility operating on an online server and database. The net server is the occasion that you simply create in Lightsail, and consists of WordPress software program and the MySQL database. The next diagram reveals the Lightsail VPC structure.

Lightsail's VPC Architecture

The database shops an enormous chunk of the info that WordPress wants; for instance, all the person account info and weblog posts. Nevertheless, the internet server’s file system shops one other portion of information; for instance, a brand new picture you add to your WordPress server. Lastly, with themes and plugins, each the database and the file system retailer info. For instance, the database holds info on what plugins and which theme is presently lively, however the file system shops the precise code for the themes and plugins.

To offer a extremely out there WordPress implementation, you might want to present redundancy not just for the database, but additionally the content material that will reside on the file system.


This answer has the next conditions:

This submit and the next posts take care of organising a brand new WordPress website. You probably have an current website, the processes to comply with are related, however you must seek the advice of the documentation for each Lightsail and WordPress. Additionally, remember to again up your current database in addition to snapshot your current WordPress occasion.

Configuring the database

The standalone MySQL database you created shouldn’t be but configured to work with WordPress. You have to create the precise database and outline the tables that WordPress wants. The simplest technique is to export the desk from the database in your WordPress occasion and import it into your standalone MySQL database. To take action, full the next steps:

  1. Connect with your WordPress occasion through the use of your SSH consumer or the web-based SSH consumer within the Lightsail console. The screenshot under highlights the icon to click on.

WordPress icon for connecting through SSH

  1. From the terminal immediate to your WordPress occasion, set two setting variables (LSDB_USERNAME and LSDB_ENDPOINT) that include the connection info to your standalone database.

You will discover that info on the database’s administration web page from the Lightsail console. See the next screenshot of the Connection particulars web page.

the Connection details page

  1. To set the setting variables, substitute the values to your occasion into the next code instance and enter every line separately on the terminal immediate:



For instance, your enter ought to look just like the next code:


  1. Retrieve the Bitnami utility password for the database operating in your WordPress occasion.

This password is saved at /residence/bitnami/bitnami_application_password.

Enter the next cat command within the terminal to show the worth:

cat /residence/bitnami/bitnami_application_password

  1. Copy and paste the next code right into a textual content doc and duplicate the password

cat /residence/bitnami/bitnami_application_password

You want this password within the following steps.

  1. Enter the next command into the terminal window:


 -u root

--databases bitnami_wordpress



-p > dump.sql

This command creates a file (dump.sql) that defines the database and all of the wanted tables.

  1. When prompted for a password, enter the Bitnami utility password you recorded beforehand.

The terminal window doesn’t present the password as you enter it.

Now that you’ve got the appropriate database construction exported, import that into your standalone database. You’ll do that by getting into the contents of your dump file into the mysql command line.

  1. Enter the next command on the terminal immediate:

cat dump.sql | mysql




  1. When prompted for a password, enter the password to your Lightsail database.

The terminal window doesn’t present the password as you enter it.

  1. Enter the next mysql command within the occasion terminal:

echo 'use bitnami_wordpress; present tables' |





This command reveals the construction of the WordPress database, and verifies that you simply created the database in your Lightsail occasion efficiently.

  1. When prompted for a password, enter the password to your standalone database.

It is best to obtain the next output:














This take a look at confirms that your standalone database is prepared so that you can use along with your WordPress occasion.

Configuring WordPress

Now that you’ve got the standalone database configured, modify the WordPress configuration file (wp-config.php) to direct the WordPress occasion to make use of the standalone database as a substitute of the database on the occasion.

Step one is to again up your current configuration file. In the event you run into bother, copy wp-config.php.bak over to wp-config.php to roll again any adjustments.

  1. Enter the next code:

cp /residence/bitnami/apps/wordpress/htdocs/wp-config.php /residence/bitnami/apps/wordpress/htdocs/wp-config.php.bak

You’re utilizing wp-cli to change the wp-config file.

  1. Swap out the next values with these to your Lightsail database:

wp config set DB_USER UserName

wp config set DB_PASSWORD Password

wp config set DB_HOST Endpoint

The next screenshot reveals the instance database values.

example database values

For instance:

wp config set DB_USER dbmasteruser

wp config set DB_PASSWORD ‘MySecurePassword!2019’

wp config set DB_HOST

To keep away from points with any particular characters the password could include, be sure to wrap the password worth in single quotes (‘).

  1. Enter the next command:

wp config record

The output ought to match the values on the database’s administration web page within the Lightsail console. This confirms that the adjustments went by.

  1. Restart WordPress by getting into the next command:

sudo /decide/bitnami/ restart


This submit lined a number of floor. Hopefully it educated and impressed you to enroll in a free AWS account and begin constructing out a sturdy WordPress website. Subsequent posts on this sequence present take care of your uploaded media and scale the internet the front conclusion with a Lightsail load balancer.

Make sure you take a look at half two within the sequence, Utilizing Amazon S3 with WordPress to securely ship media recordsdata.

Leave a Reply

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