WordPress Deployment on AWS EC2 instance with AWS RDS (MySQL) database

Ankit Shukla
3 min readJul 31, 2023

--

Greetings and best wishes for an insightful read😇 ,

Hope this blog finds you great and healthy !!😊

Lets begin with brief introduction about me…..

Hi, This is Ankit Shukla and In this article we will discuss about deployment of WordPress on AWS EC2 with RDS database.

To deploy WordPress in an EC2 instance with an Amazon RDS MySQL database, follow these steps:

Step 1: Set Up Amazon RDS (MySQL) Database

→ Go to the AWS Management Console and navigate to the Amazon RDS service.

→ Click on “Create database.”

→ Select “MySQL” as the engine type.

→ Choose the “Free tier” template for the instance class (db.t2.micro).

→ Set the master username and password for the database.

→ Configure the database settings as needed (database name, storage, etc.).

→ Make sure to set the database to be publicly accessible (for this example) or configure the security group to allow the EC2 instance to access the RDS instance.

→ Click on “Create database” to create the RDS (MySQL) instance.

Step 2: Launch an EC2 Instance

→ Go to the AWS Management Console and navigate to the EC2 service. → Click on “Launch Instance.”

→ Select an Amazon Linux AMI (or any other suitable AMI of your choice) for the instance.

→ Choose an instance type (e.g., t2.micro) that fits the free tier.

→ Configure the instance details, including network settings and security group rules. Make sure to allow HTTP (port 80) and SSH (port 22) access to the instance.

→ In the “Configure Security Group” step, make sure to add a rule for MySQL/Aurora (port 3306) and set the source to the security group of your RDS instance.

→ Add storage and tags as needed.

→ Review the instance settings and click “Launch.”

→ Select or create a key pair and click “Launch Instances.”

Step 3: Connect to the EC2 Instance

→ Once the EC2 instance is running, you can connect to it using SSH.

→ Open a terminal on your local machine and use the following command to connect to the instance:

ssh -i path/to/your/keypair.pem ec2-user@your_ec2_instance_public_ip

→ Replace path/to/your/keypair.pem with the path to your key pair file and your_ec2_instance_public_ip with the public IP address of your EC2 instance.

Step 4: Install Apache, PHP, and WordPress

→ Update the package manager and install necessary packages:

sudo yum update -y 
sudo yum install -y httpd php mysql

→ Start the Apache web server:

sudo service httpd start
sudo chkconfig httpd on

→ Download and extract WordPress:

cd /var/www/html
sudo wget https://wordpress.org/latest.tar.gz
sudo tar -xzvf latest.tar.gz

→ Create a configuration file for WordPress:

sudo mv /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php

→ Configure the WordPress database settings in wp-config.php:

sudo vi /var/www/html/wordpress/wp-config.php

Set the database name, username, password, and the RDS endpoint or connection string you obtained when setting up the RDS instance.

→ Set proper permissions:

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

Step 5: Access WordPress

→ Open a web browser and navigate to your EC2 instance’s public IP address.

→ Complete the WordPress installation by following the on-screen instructions.

→ Once installed, you can start using WordPress on your EC2 instance with the RDS MySQL database.

Please Apply all the steps mentioned above …it will help you to accomplish task.

Thanks For Reading !!🙂

--

--

Ankit Shukla
Ankit Shukla

Written by Ankit Shukla

| Software Developer | SDET |

No responses yet