Day 45: Deploy WordPress website on AWS

Day 45: Deploy WordPress website on AWS

ยท

3 min read

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

  1. Log in to your AWS Management Console.

  2. Navigate to the Amazon RDS service.

  3. Click on "Create database" and choose MySQL as the database engine.

  4. Configure the database settings including instance type, username, password, and database name

  5. Adjust additional settings such as storage, backups, and monitoring.

  6. Click on "Create database" to provision the RDS instance.

Step 2: Configure Amazon EC2 Instance

  1. Go to the EC2 dashboard in the AWS Management Console.

  2. Click on "Launch instance" and select a suitable AMI (Amazon Machine Image).

  3. Choose an instance type, configure network settings, and set up security groups.

  4. Create or select an existing key pair for SSH access.

  5. Review and launch the EC2 instance.

Step 3: Establish Connection between WordPress and MySQL

  1. Obtain the endpoint of the RDS instance from the Amazon RDS dashboard.

  2. SSH into your EC2 instance using the key pair.

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

     sudo apt install mysql-client-core-8.0
    

  4. Connect to your MySQL database using the following command:

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

  5. 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

  1. Download the latest version of WordPress from the official website or using command-line tools.

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

  2. Extract the WordPress files to the document root of your web server on the EC2 instance.

     tar -xzf latest.tar.gz
    

  3. Configure the web server (e.g., Apache or Nginx) to serve the WordPress files.

     sudo apt-get install apache2
     sudo systemctl restart apache2
    

  4. Configure WordPress to connect to the MySQL database by editing the wp-config.php file.

  5. Enter the RDS endpoint, database name, username, and password in the wp-config.php file.

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

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

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

     sudo cp -r wordpress/* /var/www/html/
    
  8. Restart the Apache web server.

     sudo systemctl restart apache2
    
  9. You can now access the WordPress welcome page by navigating to ec2-public-ip/wp-admin

    No alt text provided for this image

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.

๐Ÿ’ก
Feel free to drop any questions ๐Ÿค” or requests for help in the comments section! I would be happy to answer them!
๐Ÿ’ก
If you found this information helpful, a thumbs up๐Ÿ‘ and a follow would be greatly appreciated! Your support means the world to me.

Thank you for taking the time to read! ๐Ÿ’š

Did you find this article valuable?

Support Akash Dhengale by becoming a sponsor. Any amount is appreciated!

ย