🚀Day 45: Deploy Wordpress website on AWS💻

🚀Day 45: Deploy Wordpress website on AWS💻

WordPress serves as the content management system (CMS) for more than 30% of all websites on the internet. It may be used to manage e-commerce sites, discussion boards, and many other well-known things, but blogs are where it is most frequently utilized. You may learn how to set up a WordPress blog site by reading this guide.

Task-01

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

Visit the Amazon RDS interface. the "Create database" button.

No alt text provided for this image

Make "MySQL" your engine type choice.

No alt text provided for this image

For the "Database instance class" template, select the "Free tier" option.

No alt text provided for this image

Give the "Database instance identification" a unique name.

Set the "Master username" and "Master password" for the database.

No alt text provided for this image

Configure the instance's "Virtual Private Cloud (VPC)" and "Subnet Group" settings. Maintain the default values for the other parameters.

No alt text provided for this image

No alt text provided for this image

Choose 'Default VPC'

No alt text provided for this image

No alt text provided for this image

Click on "create database"

No alt text provided for this image

The database was created.

No alt text provided for this image

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

WordPress installation and hosting on an Amazon EC2 instance.

access the Amazon EC2 console. Choose a Linux AMI by clicking "Launch Instance."

Select a VPC and subnet, and then a kind of instance, such as t2.micro.

Set up security group rules so that incoming traffic is permitted on the correct port for the type of database you're using (e.g. port 3306 for MySQL).

No alt text provided for this image

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

Choose the MySQL database you just established, navigate to the Connectivity & Security tab, and select the VPC security group. You may access the security group set up for your database using the console.

No alt text provided for this image

To modify the rules for your security group, select the Incoming Rules tab and then the Edit inbound rules button.

By changing the Type attribute to MYSQL/Aurora, the Protocol and Port range will be updated to the correct settings.

The security group that you used for your EC2 instance should be selected.

No alt text provided for this image

Enter your EC2 instance via SSH.

No alt text provided for this image

Install a MySQL client in your terminal to access the database by running the following command:

sudo apt install mysql-client-core-8.0

No alt text provided for this image

No alt text provided for this image

Use the following command to connect to your MySQL database in your terminal. Substitute your master username and password for "user" and "password," which you specified when you created your Amazon RDS database. The RDS database endpoint for -h is the host.

mysql -h <rds-database-endpoint> -P <port-no> -u <user> -p <password>

No alt text provided for this image

Create a database user for your WordPress application, and then grant access to the WordPress database to the user.

Enter the commands below into your terminal:

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

To protect your database, you ought to use a stronger password than WordPress-pass.

No alt text provided for this image

On your EC2 instance, you must operate a web server in order to run WordPress.

Run the following command in your terminal in order to install Apache on your EC2 instance:

sudo apt-get install apache2

No alt text provided for this image

In your terminal, type the following command to launch the Apache web server:

systemctl restart apache2

By accessing your ec2 instance's public IP, you may verify that your Apache web server is operational.

No alt text provided for this image

Set up the server and post your new WordPress app.

Use the following commands in your terminal to first download and uncompress the software:

wget https://wordpress.org/latest.tar.g
tar -xzf latest.tar.gzz

No alt text provided for this image

With the ls command, you will notice a tar file and a directory called WordPress that contains the uncompressed contents.

No alt text provided for this image

open the wp-config.php file

No alt text provided for this image

Modify the following lines in the database configuration:

No alt text provided for this image

  1. DB_NAME: your RDS database name

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

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

  4. DB_HOST: The hostname of the database means your database endpoint

The Authentication Unique Keys and Salts configuration area is the second one that needs to be set up.

You can substitute the following text for everything in that section:

Make sure to create the following details with https://api.wordpress.org/secret-key/1.1/salt

define('AUTH_KEY',         'Z9-CmDhIDuNlO8t5EM[+xf-[`VJ)_A>qknjR>Kat$2a6=oYF_-|%H+4MkJW^!t9x');
define('SECURE_AUTH_KEY',  '(sIg&e-5bk|&=ruFb0LLF,P$&kFS_L+B]ovbC@wEN`@mE~V q?TWzMvz;v3ZGnF1');
define('LOGGED_IN_KEY',    'ZA(ia@)uP7i#Z.=$`jBZPv|IUW=6|;+xuTcPCYR+f.U[i((;nS,!?0z!ifYY$O=F');
define('NONCE_KEY',        'c3k|3LBocTe%J#-|Lnl%8eL,TD3,nV-AU|Y(M*|Vy:##dJT{KMNzDu*J7e9:xbX=');
define('AUTH_SALT',        '+mRr-[sDf-KsN&i;*qVjUkDV=A-n.&]G~oVH&J0M,taM,1>vkjjuOiQm6RIhUmmo');
define('SECURE_AUTH_SALT', 'dmOHiQah U<_Z+np}D>i=~0f[5hv509+E/8WNymuQ5P/-j#h&TO>tY5HHM$qG,Pt');
define('LOGGED_IN_SALT',   '=X|}omdoywp,j.1eq;z0dmK],|*s1FJ5kf<Q7+-qr jX/VgOub++FgBX8E,8<}r2');
define('NONCE_SALT',       '/dNw0(+[W.@-8|kXMppSKv0e1>@P_|b05y-GS^!Hb`!Xj0Z+L-VGm|? K9`krU/1');

No alt text provided for this image

Make sure you have replaced the text with the text you have created.

Installing WordPress application dependencies comes first. Activate the following command in your terminal.

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

No alt text provided for this image

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

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

No alt text provided for this image

Finally, restart the Apache web server

systemctl restart apache2

The WordPress welcome page should be visible if you navigate to "ec2-public-ip/wp-admin/".

No alt text provided for this image

I appreciate you continuing to read; I hope you learned something. ❤️🙌