Deploy WordPress over EC2 instance using AWS RDS as MySQL database server

Steps to complete this task:

  • We need to create a MySQL database using AWS RDS.
  • Create a EC2 instance
  • WordPress stores data at the backend in the MySQL Database Server which we have created using RDS service of AWS, Configure RDS database
  • Configuring httpd server on EC2 instance
  • Configuring Wordpress, provide the endpoint/connection string to the WordPress application to make it work.
  • Deploying Wordpress

Step 1: Creating a MySQL database using AWS RDS

Click on create database , select options according to free tier

  • choose MySQL as engine type.
  • give DB name and set credentials
  • Additional configuration
  • Click on create database

Step 2: Create EC2 instances

  • Choose Amazon Linux image for instance
  • while security group settings, create a new security group, add rule for HTTP with as source.
  • launch instance with this settings

Step 3: Configuring RDS

  • Go to database that we have created, then go to connectivity & security of that click on security group edit SG inbound rule choose MYSQL/Aurora as type and give source as custom choose the SG same that we have created for EC2 instance, this will allow access of EC2 in database.
  • Log in to the EC2 instance via SSH
  • install MySQL
  • Now go to database and then copy the endpoint from connectivity & security session.
  • give command for connecting mysql
  • Give the following command for creating user for Wordpress application and set permission for accessing database.

Step 4: Configuring httpd server on EC2 instance

  • “sudo yum install httpd” for installing httpd
  • starting service “sudo service httpd start”
  • checking if the httpd is working or not

Step 5: Configuring Wordpress

  • Downloading wordpress
  • uncompress wordpress
  • ls and then you can see Wordpress and latest.tar.gz directories
  • “cd wordpress”
  • “cp wp-config-sample.php wp-config.php” copying sample config file content to original file
  • “nano wp-config.php” to edit file
  • change dbname, password, user, host from previous steps

Step 6: Deploying Wordpress

  • installing lamp-mariadb10.2-php7.2 from amazon-linux-extras
  • copy wordpress to /var/www/html and restart service
  • Reload httpd page you can see wordpress now
  • you can see database info

Successful in deploying Wordpress application on EC2 instance using AWS RDS as database.

Thank you.