This is #90DaysofDevops challenge under the guidance of Shubham Londhe sir.
Introduction
Welcome to Day 45 of our AWS journey! Today, we'll guide you through the process of deploying a WordPress website on Amazon Web Services (AWS) using Amazon RDS for MySQL and Amazon EC2.
Task-01: Setting Up WordPress on AWS To initiate the WordPress deployment on AWS, the following steps are essential:
Step 1: Provision Amazon RDS Instance for MySQL
Log in to your AWS Management Console.
Navigate to the Amazon RDS service.
Click on "Create database" and choose MySQL as the database engine.
Configure the database settings including instance type, username, password, and database name
Adjust additional settings such as storage, backups, and monitoring.
Click on "Create database" to provision the RDS instance.
Step 2: Configure Amazon EC2 Instance
Go to the EC2 dashboard in the AWS Management Console.
Click on "Launch instance" and select a suitable AMI (Amazon Machine Image).
Choose an instance type, configure network settings, and set up security groups.
Create or select an existing key pair for SSH access.
Review and launch the EC2 instance.
Step 3: Establish Connection between WordPress and MySQL
Obtain the endpoint of the RDS instance from the Amazon RDS dashboard.
SSH into your EC2 instance using the key pair.
Install a MySQL client in your terminal to access the database by running the following command:
sudo apt install mysql-client-core-8.0
Connect to your MySQL database using the following command:
mysql -h <rds-database-endpoint> -P <port-no> -u <user> -p <password>
Create a database user for your WordPress application and grant access to the WordPress database.
- Execute 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
Step 4: Deploy WordPress on EC2 Instance
Download the latest version of WordPress from the official website or using command-line tools.
wget https://wordpress.org/latest.tar.gz
Extract the WordPress files to the document root of your web server on the EC2 instance.
tar -xzf latest.tar.gz
Configure the web server (e.g., Apache or Nginx) to serve the WordPress files.
sudo apt-get install apache2 sudo systemctl restart apache2
Configure WordPress to connect to the MySQL database by editing the wp-config.php file.
Enter the RDS endpoint, database name, username, and password in the wp-config.php file.
Installing WordPress application dependencies comes first. Activate the following command in your terminal.
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/
Restart the Apache web server.
sudo systemctl restart apache2
You can now access the WordPress welcome page by navigating to
ec2-public-ip/wp-admin
Conclusion
Congratulations! You have successfully deployed WordPress on AWS using Amazon RDS for MySQL and Amazon EC2. Your WordPress site is now ready for customization and content creation. Stay tuned for more tutorials on optimizing and securing your WordPress deployment on AWS.