Launch WordPress application on EC2 Instance on top of apache webserver with backend as MySQL using AWS RDS

Akurathi Sri Krishna Sagar
4 min readJun 7, 2021

--

First, we start the task by launching MySQL database using AWS RDS Service.

Go to AWS RDS and click on “Create database” :

Select the Standard Create and MySQL as Database :

I’ve selected the MySQL version 5.7.31 because it is best compatible for the WordPress :

Select the Free tier if you are doing for just practice :

Give a name for your database, Create the Master username, password :

The DB instance class is optimized for the Databases. I’m leaving the t2.micro as it is :

Now, you can set the Size of Database you want. The storage autoscaling will be enabled by default. You can disable if you want. I have set the Maximum threshold to 30GiB :

I’m selecting the default VPC, subnet, security group and for a security purpose, disabling the public connectivity. I’m choosing ap-south-1 as the preferred AZ :

Give an initial Database Name :

Finally, Click “Create Database”. After sometime, the database is started :

Now, go to EC2 Service in AWS and launch an Amazon Linux Instance. I’m launching a t2.micro instance. Note: You must launch the instance in the same VPC you gave for the MySQL.

My instance is running :

I’ve connected to Instance through Web Console. You can login using the key also :

Install the following software using yum or dnf :

yum install php-mysqlnd php-fpm httpd php-json php -y

If you are using Amazon Linux Instance, run :

amazon-linux-extras install lamp-mariadb10.2-php7.2 php7.2

Download wordpress using the command :

curl https://wordpress.org/latest.tar.gz --output wordpress.tar.gz

Extract the tar file using the command :

tar xvf wordpress.tar.gz

Now, you will get the following wordpress folder :

Copy the wordpress folder recursively to the Document root of apache web server : /var/www/html with the command :

cp -r wordpress /var/www/html

Run the following commands to change the SELinux Security Context :

chown -R apache:apache /var/www/html/wordpress

Now, restart the apache web server using the command :

systemctl restart httpd

You can enable the httpd service permanently with the command :

systemctl enable httpd

If everything is success, you will see the following page when you type in your Public IP in the Browser :

Click “Let’s go”. Provide the Database name, Usernam, Password, Database Host (Endpoint which is visible in AWS website). Click Submit :

If you see the following, just do the steps mentioned in it and Click “Run the Installation” :

Now, provide the Custom site title, username, email, password and click “Install WordPress” :

Now, you can login to the WordPress using your credentials :

If everything is successful, you can finally view the WordPress dashboard :

Now, go to RDS and view your database and you can see 1 connections :

Wow. Now, you have launched WordPress application over AWS Instance with backend as MySQL provided by Amazon RDS Service in AWS!

Thanks for Reading ☺

--

--

No responses yet