# Day 45 : Deploy WordPress website on AWS

### 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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753547905868/66b499b3-a6c5-4ca4-bece-d5d526d3b911.png align="center")

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753548105370/91efedfe-9c3f-48e6-b6e2-dd3e4674a22b.png align="center")

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753548291871/80d90929-26a3-464f-b279-e5d3647f7a10.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753548417767/a3d22315-5c37-4179-bf8a-3f82d2a3e947.png align="center")

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

mysql -h &lt;endpoint address&gt; -P &lt;[port.no](http://port.no)\&gt; -u -p

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753548471313/7aa5491c-397a-4cc3-9b0a-93dd1b31c3be.png align="center")

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753548534309/92bc92e9-baca-480e-a945-4835692b30d4.png align="center")

Now Install apache2 on the ubuntu server.

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753548651176/7a136b84-45e0-486e-b17e-6a09b5768786.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753548662960/50088146-33a1-42bc-a01f-dd35c652cedb.png align="center")

Install and extract WordPress on the server using below commands

wget [https://wordpress.org/latest.tar.gz](https://wordpress.org/latest.tar.gz)

tar -xzf latest.tar.gz

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753548729091/a2dc0ac8-2012-4295-8bd8-a5b2d412a1da.png align="center")

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753548977936/81e1a353-997d-4d2c-ae50-a9f4c9aecbee.png align="center")

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' ); ——&gt; mention wordpress db created initially

/\*\* MySQL database username \*/

define( 'DB\_USER', 'username\_here' ); ——&gt; 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](http://localhost)' ); —→ mention rds endpoint in local host

Use link “[https://api.wordpress.org/secret-key/1.1/salt/](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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753549211501/ce91a036-01e4-46bc-88d8-60fee9065ddd.png align="center")

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753549245561/57db2ab2-c641-4b35-a553-39b8364c0c9e.png align="center")

Restart the apache server

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753549289682/26e18781-c4c1-44fe-aa85-4416b8d96fb5.png align="center")

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753549323379/540f8190-63a5-4425-ba32-8f1583cda3e6.png align="center")

Create a username and password to login into wordpress website

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753549346865/07b3fac4-6760-4222-a3f1-21510367cac5.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753549354732/3227dde4-6f20-43da-9349-6423dafe1b10.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753549362689/7a9312f4-fec2-4f6d-8fd5-5295f33ddb6d.png align="center")
