Introduction
WordPress, the world's most popular Content Management System (CMS), can be seamlessly deployed on Amazon Web Services (AWS) for a scalable and reliable web experience. In this blog post, we'll guide you through the process of deploying a WordPress website on AWS, leveraging the power of Amazon EC2 for hosting and Amazon RDS for MySQL as the database backend.
Task-01: Create an RDS for MySQL Database
Before configuring the WordPress site, let's set up the MySQL database using Amazon RDS.
Step 1: Log in to AWS Management Console
Navigate to the AWS Management Console and log in to your AWS account.
Step 2: Access Amazon RDS
Click on the "Services" dropdown, select "RDS" under the Database category.
Step 3: Create a New RDS Instance
Click on "Create database."
Choose "MySQL" as the database engine.
Select the desired version and template (choose the "Free tier" if applicable).
Configure the instance details, including DB instance identifier, master username, and password.
Set up additional configurations such as DB instance size, storage, and networking.
Review your settings and click "Create database."
Step 4: Wait for RDS Instance to be Available
The RDS instance creation process may take a few minutes. Once it's available, note down the endpoint for future reference.
Task-02: Set Up Amazon EC2 Instance for WordPress
Step 1: Navigate to EC2 Dashboard
Go to the AWS Management Console.
Click on "Services" and select "EC2" under the Compute category.
Step 2: Launch a New EC2 Instance
Click "Launch Instance."
Choose an Amazon Machine Image (AMI) – select an image that suits your requirements.
Select an instance type, configure instance details, storage, and add tags as needed.
Configure security groups to allow traffic on port 80 (HTTP) and port 443 (HTTPS).
Review your configurations and launch the instance.
Step 3: Connect to EC2 Instance
Once the instance is running, connect to it using SSH.
Connect the EC2 instance to the RDS instance.
Task-03: Install and Configure WordPress
Step 1: Download and Install WordPress
SSH into your EC2 instance.
Download and install WordPress:
sudo apt-get update sudo apt-get install apache2 mysql-server php php-mysql libapache2-mod-php php-cli sudo service apache2 start sudo service mysql start sudo wget https://wordpress.org/latest.tar.gz sudo tar -xzf latest.tar.gz -C /var/www/html/
Step 2: Configure WordPress
Create a WordPress configuration file:
cd /var/www/html/wordpress sudo cp wp-config-sample.php wp-config.php
Edit the configuration file with your RDS database details:
sudo vim wp-config.php
Update the following lines with your RDS database details:
define('DB_NAME', 'your_database_name');
define('DB_USER', 'your_database_user');
define('DB_PASSWORD', 'your_database_password');
define('DB_HOST', 'your_rds_endpoint');
- Save and close the file.
Step 3: Access WordPress
Open your web browser and navigate to your EC2 instance's public IP or domain.
Complete the WordPress installation by entering the required details.
Conclusion
Congratulations! You've successfully deployed a WordPress website on AWS, integrating Amazon EC2 for hosting and Amazon RDS for MySQL as the backend database. Stay tuned for more DevOps adventures in the remaining days of the 90 Days of DevOps challenge!
Follow me on LinkedIn.
Checkout my GitHub profile.