Day 45 : Deploy WordPress website on AWS

Rahul SinghRahul Singh
3 min read

What is WordPress?

WordPress is a web content management system. It was originally created as a tool to publish blogs but has evolved to support publishing other web content, including more traditional websites, mailing lists, Internet forums, media galleries, membership sites, learning management systems, and online stores

Task-01

  • As WordPress requires a MySQL database to store its data ,create an RDS

To configure this WordPress site, you will create the following resources in AWS:

  • An Amazon EC2 instance to install and host the WordPress application.

  • An Amazon RDS for MySQL database to store your WordPress data.

  • Setup the server and post your new WordPress app.

Create an EC2 instance — Go to the Amazon EC2 console. Click “Launch Instance”. Choose a Ubuntu AMI. Choose an instance type, such as t3.micro. Choose a VPC and subnet. Click on “Launch Instance”.

Ensure port 3306 is opened in ec2 server security group for communication with mysql

Now create a rds instance and note down username, password and endpoint

Login into ec2 instance and install mysql client using command “sudo apt-get install mysql-client”

Connect to the RDS instance using the MySQL client with the endpoint address, username, and password:

mysql -h <endpoint address> -P <port.no\> -u -p

Run the below commands to create a database and user.

CREATE DATABASE wordpress;

CREATE USER 'wordpress' IDENTIFIED BY 'wordpress-pass';

GRANT ALL PRIVILEGES ON wordpress.* TO wordpress;

FLUSH PRIVILEGES;

Exit

Now Install apache2 on the ubuntu server.

sudo apt-get update && sudo apt install -y apache2

Install and extract WordPress on the server using below commands

wget https://wordpress.org/latest.tar.gz

tar -xzf latest.tar.gz

Rename the sample wp-config file to wp-config.php and edit it using any editor

We need to edit 2 configurations, 1st the db details and 2nd the token details

// MySQL settings - You can get this info from your web host // /** The name of the database for WordPress */

define( 'DB_NAME', 'database_name_here' ); ——> mention wordpress db created initially

/** MySQL database username */

define( 'DB_USER', 'username_here' ); ——> mention username for wordpress db

/** MySQL database password */

define( 'DB_PASSWORD', 'password_here' ); —→ mention password for wordpress db user

/** MySQL hostname */

define( 'DB_HOST', 'localhost' ); —→ mention rds endpoint in local host

Use link “https://api.wordpress.org/secret-key/1.1/salt/” to generate auth token

Install the dependency of the application on the server.

sudo apt install php libapache2-mod-php php-mysql -y

Copy the file contents from the WordPress folder to /var/www/html folder to configure the application with Apache web server.

Restart the apache server

Navigate to /wp-admin/ to view the WordPress website.

Create a username and password to login into wordpress website

0
Subscribe to my newsletter

Read articles from Rahul Singh directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Rahul Singh
Rahul Singh