This document provides instructions for deploying a fault-tolerant WordPress site using Amazon RDS and AWS Elastic Beanstalk. It describes launching a MySQL database instance on RDS for use with the WordPress site, creating an Elastic Beanstalk environment connected to that database, and deploying the WordPress code. Key steps include launching the RDS instance, modifying security groups to allow access from the Elastic Beanstalk environment, configuring the environment to connect to the database, and deploying and installing WordPress. This architecture decouples the database from Elastic Beanstalk environments to provide high availability.
2. Fault tolerant Word Press
Site
2
▪ How you launch an Amazon RDS DB instance that
is external to AWS Elastic Beanstalk?
▪ How to configure a high-availability environment
running aWordPress website to connect to it.
Running a DB instance external to Elastic
Beanstalk decouples the database from the
lifecycle of your environment.
▪ This lets you connect to the same database from
multiple environments, swap out one database for
another, or perform a blue/green deployment
without affecting your database.
3. Fault tolerant Word Press
Site
3
▪ Launch a DB Instance in Amazon RDS
– To use an external database with an application running in Elastic Beanstalk,
first launch a DB instance with Amazon RDS.When you launch an instance
with Amazon RDS, it is completely independent of Elastic Beanstalk and your
Elastic Beanstalk environments, and will not be terminated or monitored by
Elastic Beanstalk.
– Use the Amazon RDS console to launch a Multi-AZ MySQL DB instance.
Choosing a Multi-AZ deployment ensures that your database will fail over
and continue to be available if the master DB instance goes out of service.
4. Fault tolerant Word Press
Site
4
▪ Launch a DB Instance in Amazon RDS
– To launch an RDS DB instance in a defaultVPC
▪ Open the RDS console.
▪ Choose Instances in the navigation pane.
▪ Choose Launch DB instance.
▪ Choose a database engine. Choose Next.
▪ Choose a use case, if prompted.
▪ Under Specify DB details, review the default settings and adjust as necessary. Pay
attention to the following options:
– DB instance class – Choose an instance size that has an appropriate amount of memory and CPU
power for your workload.
– Multi-AZ deployment – For high availability, set to Create replica in different zone.
– Master username and Master password –The database username and password. Make a note of
these settings because you'll use them later.
▪ Choose Next.
▪ Under Database options, for Database name, type ebdb. Make a note of the Database
port value for use later.
▪ Verify the default settings for the remaining options, and choose Launch DB instance.
5. Fault tolerant Word Press
Site
5
▪ Next, modify the security group attached to your DB instance to
allow inbound traffic on the appropriate port.This is the same
security group that you will attach to your Elastic Beanstalk
environment later, so the rule that you add will grant ingress
permission to other resources in the same security group.
▪ To modify the ingress rules on your RDS instance's security
group
1. Open the Amazon RDS Console.
2. Choose Instances.
3. Choose the name of your DB instance to view its details.
4. Under Details section, note the Subnets, Security groups,
and Endpoint shown on this page so you can use this information later.
6. Fault tolerant Word Press
Site
6
5. Under Security and network, you can see the security group
associated with the DB instance. Open the link to view the
security group in the Amazon EC2 console.
7. Fault tolerant Word Press
Site
7
6. In the security group details, choose Inbound.
7. Choose Edit. & Choose Add Rule.
8. ForType, choose the DB engine that your application uses.
9. For Source, type sg- to view a list of available security groups.
Choose the current security group to allow resources in the
security group to receive traffic on the database port from other
resources in the same group.
8. Fault tolerant Word Press
Site
8
10. Choose Save.
11. Creating a DB instance takes about 10 minutes. In the meantime,
downloadWordPress and create your Elastic Beanstalk
environment.
DownloadWordPress
To prepare to deployWordPress using AWS Elastic Beanstalk, you must copy the
WordPress files to your computer and provide some configuration information.
To create aWordPress project
1. DownloadWordPress from wordpress.org.
2. Download the configuration files from the sample repository:
~$ wget https://github.com/aws-samples/eb-php-
wordpress/releases/download/v1.1/eb-php-wordpress-v1.zip
3. ExtractWordPress and change the name of the folder.(“wordpress-
beanstalk”)
9. Fault tolerant Word Press
Site
9
▪ Launch an Elastic Beanstalk Environment
▪ Use the AWS Management Console to create an Elastic Beanstalk
environment. Choose the PHP platform and accept the default settings
and sample code. After you launch the environment, you can configure
the environment to connect to the database, then deploy the WordPress
code to the environment.
▪ To launch an environment (console)
1. Open the Elastic Beanstalk console using this preconfigured
link: console.aws.amazon.com/elasticbeanstalk/home#/newApplication?applic
ationName=tutorials&environmentType=LoadBalanced&instanceType=t2.micr
o
2. For Platform, choose the platform that matches the language used by your
application.
3. For Application code, choose Sample application.
4. Choose Review and launch.
5. Review the available options.When you're satisfied with them, choose Create
app.
10. Fault tolerant Word Press
Site
10
▪ Configure Security Groups and Environment Properties
▪ Add the security group of your DB instance to your running environment.
This procedure causes Elastic Beanstalk to reprovision all instances in
your environment with the additional security group attached.
▪ To add a security group to your environment
1. Open the Elastic Beanstalk console.
2. Navigate to the management page for your environment.
3. Choose Configuration.
4. On the Instances configuration card, choose Modify.
5. Under EC2 security groups, choose the security group to attach to the
instances, in addition to the instance security group that Elastic Beanstalk
creates.
6. Choose Apply.
7. Read the warning, and then choose Confirm.
11. Fault tolerant Word Press
Site
11
▪ Next, use environment properties to pass the connection
information to your environment.The sample application uses a
default set of properties that match the ones that Elastic Beanstalk
configures when you provision a database within your
environment.
▪ To configure environment properties for an Amazon RDS DB
instance
1. Open the Elastic Beanstalk console.
2. Navigate to the management page for your environment.
3. ChooseConfiguration.
4. On the Software configuration card, choose Modify.
5. In the Environment properties section, define the variables that your
application reads to construct a connection string. For compatibility with
environments that have an integrated RDS DB instance, use the following.
13. Fault tolerant Word Press
Site
13
▪ Configure and DeployYour Application
▪ Verify that the structure of your wordpress-beanstalk folder is
correct, as shown.
▪ To deploy a source bundle
1. Open the Elastic Beanstalk console.
2. Navigate to the management page for your environment.
3. Choose Upload and Deploy.
4. Choose Choose File and use the dialog box to select the source bundle.
5. Choose Deploy.
6. When the deployment completes, choose the site URL to open your
website in a new tab.
14. Fault tolerant Word Press
Site
14
▪ Install WordPress
▪ To complete your WordPress installation
1. Open the Elastic Beanstalk console.
2. Navigate to the management page for your environment.
3. Choose the environment URL to open your site in a browser.You are
redirected to aWordPress installation wizard because you haven't configured
the site yet.
4. Perform a standard installation.The wp-config.php (github repo)file is already
present in the source code and configured to read the database connection
information from the environment.You shouldn't be prompted to configure
the connection.
▪ Installation takes about a minute to complete.
▪ Finally, if you plan on using your application in a production
environment, you will want to configure a custom domain name for
your environment and enable HTTPS for secure connections.