I created a MySQL RDS instance on AWS. I also created an EC2 instance on which I installed Wordpress, Apache, MySQL client, and other dependencies using the script shown below.
-- Script
#!/bin/bash
yum update -y
yum install httpd php php-mysql -y
cd /var/www/html
echo "healthy" > healthcheck.html
wget https://wordpress.org/wordpress-5.1.1.tar.gz
tar -xzf wordpress-5.1.1.tar.gz
cp -r wordpress/* /var/www/html/
rm -rf wordpress
rm -rf wordpress-5.1.1.tar.gz
chmod -R 755 wp-content
chown -R apache:apache wp-content
chkconfig httpd on
service httpd start
I created a database and a master user while creating an RDS instance, and tried to host a Wordpress website. It shows this error every time (This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at wpsdbserver.cv3al69dy8rq.us-east-1.rds.amazonaws.com. This could mean your host’s database server is down).
Both EC2 instance and RDS instance are in the same VPC, and also I have allowed port 3306 from SecurityGroup1(Ec2) to SecurityGroup2(Rds instance). I have entered the correct username, password, and database endpoint. RDS instance has no public access. The rest of the configuration settings are set to default.