Day 45 - Setting Up WordPress on EC2 with MySQL RDS ๐ŸŒ

Day 45 - Setting Up WordPress on EC2 with MySQL RDS ๐ŸŒ

ยท

2 min read

Today, we're taking our DevOps skills to the next level by setting up WordPress on our EC2 instance, powered by MySQL RDS. Get ready for an exciting journey! ๐Ÿš€

Step 5: Connect to RDS MySQL Instance

  1. ๐Ÿ”Œ Install a MySQL client, such as mysql.

  2. ๐Ÿ–ฅ๏ธ Connect to the RDS instance using the MySQL client and the endpoint address, username, and password:

mysql -h <endpoint address> -P <port.no> -u <username> -p

  1. ๐Ÿ”‘ Enter the password when prompted and press enter. You should now be connected to the MySQL database on the RDS instance.

Step 6: Configure WordPress Database and Installation

  1. ๐Ÿ› ๏ธ 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

  1. ๐Ÿ“ฆ Download and uncompressed the WordPress software:
wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz

  1. ๐Ÿ“ Edit the wp-config.php file to configure the database:
cd wordpress
cp wp-config-sample.php wp-config.php
vim wp-config.php

  1. ๐Ÿ› ๏ธ Edit the database configuration:

    • DB_NAME: Your RDS database name

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

    • DB_PASSWORD: The password for the user

    • DB_HOST: The hostname of the RDS database (endpoint)

  2. ๐Ÿ—๏ธ Replace the Authentication Unique Keys and Salts section in wp-config.php with the provided content.

Step 7: Install Application Dependencies and Copy Files

  1. ๐Ÿ› ๏ธ Install the application dependencies for WordPress:
sudo apt update
sudo apt install php libapache2-mod-php php-mysql -y

  1. ๐Ÿ“‚ Copy your WordPress application files into the Apache directory:
sudo cp -r wordpress/* /var/www/html/

  1. ๐Ÿ”„ Restart the Apache web server:
systemctl restart apache2

  1. ๐ŸŒ Browse ec2-public-ip/wp-admin/ to see the WordPress welcome page.

Congratulations! You've successfully set up WordPress on your EC2 instance with MySQL RDS. ๐ŸŽ‰

Thank you for reading! ๐Ÿ™Œ

Did you find this article valuable?

Support Nilkanth Mistry by becoming a sponsor. Any amount is appreciated!

ย