Day 45: Deploy WordPress website on AWS

Ritul GuptaRitul Gupta
3 min read

Table of contents

Over 30% of all websites on the internet use WordPress as their content management system (CMS). It is most often used to run blogs, but it can also be used to run e-commerce sites, message boards, and many other famous things. This guide will show you how to set up a WordPress blog site.

Task-01

๐Ÿ“ข As WordPress requires a MySQL database to store its data, create an RDS as you did on Day 44

  • Create an Amazon RDS for MySQL Database

    1. Go to the Amazon RDS console.

    2. Click on "Create database" and select "MySQL" as the database engine.

    3. Configure the database details, including the DB instance identifier, username, password, database name, and other settings as per your requirements.

      1. Configure the VPC, subnet, and security group settings for the RDS instance.

  1. Finally, create the RDS database.

๐Ÿ“ข To configure this WordPress site, you will create the following resources in AWS:

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

    Run the following command in your terminal to install a MySQL client to interact with the database.

       sudo apt install mysql-client -y
    

    Run the following command in your terminal to connect to your MySQL database. Replace โ€œ<user>โ€ and โ€œ<password>โ€ with the master username and password you configured when creating your Amazon RDS database. -h is the host which is the RDS database endpoint.

      mysql -h <RDS hostname> -u <master username> -p
    

    Finally, create a database user for your WordPress application and give the user permission to access the WordPress database.

    Run the following commands in your terminal:

       CREATE DATABASE wordpress;
       CREATE USER 'wordpress' IDENTIFIED BY 'wordpress-pass';
       GRANT ALL PRIVILEGES ON wordpress.* TO wordpress;
       FLUSH PRIVILEGES;
       Exit
    

To run WordPress, you need to run a web server on your EC2 instance. To install Apache on your EC2 instance, run the following command in your terminal:

 sudo apt-get install apache2 -y

You can see that your Apache web server is working by browsing the public IP of your ec2 instance.

First, download and uncompress the software by running the following commands in your terminal:

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

You will see a tar file and a directory called WordPress with uncompressed contents using the ls command.

cp wp-config-sample.php wp-config.php

Open the wp-config.php file

  • DB_NAME: your RDS database name

  • DB_USER: The name of the user you created in the database in the previous steps

  • DB_PASSWORD: The password for the user you created in the previous steps

  • DB_HOST: The hostname of the database means your database endpoint

To configure the Authentication Unique Keys and Salts section in the WordPress wp-config.php file, you can replace the entire content in that section with the following content:

First, install the application dependencies you need for WordPress.

In your terminal, run the following command.

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

Copy your WordPress application files into the /var/www/html directory used by Apache.

 sudo cp -r wordpress/* /var/www/html/

To restart the Apache web server

 systemctl restart apache2

To access the WordPress admin dashboard, open a web browser and enter the following URL: http://ec2-public-ip/wp-admin/, where ec2-public-ip should be replaced with the public IP address or domain name of your Amazon EC2 instance.

  • ๐Ÿ“ข An Amazon RDS for MySQL database to store your WordPress data.

  • ๐Ÿ“ข Set up the server and post your new WordPress app.

ThankYou ๐Ÿ˜€

Happy learning:)

Ritul Gupta

31
Subscribe to my newsletter

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

Written by

Ritul Gupta
Ritul Gupta

Im looking for an opportunity to start a career in Cloud Technologies where I can enhance my knowledge and skills. Having knowledge and hands-on on Azure Cloud, AWS & Open Source tools - Docker, Kubernetes, Jenkins, Source Version Control, CI/CD Pipelines, and Script.