WordPress On AWS

Tirumalaparise
3 min readJan 17, 2021
image from google

🔅 Create an AWS EC2 instance

🔅 Configure the instance with Apache Webserver.

🔅 Download php application name “WordPress”.

🔅 As wordpress stores data at the backend in MySQL Database server. Therefore, you need to setup a MySQL server using AWS RDS service using Free Tier.

🔅 Provide the endpoint/connection string to the WordPress application to make it work.

To install the wordpress we require mainly 3 things namely a server to run on ,a Database to store in and php installed system.Generally wordpress is setup on LAMP stack.

  1. Create and Configuring EC2 instance as web server:

First log into Aws account and go to services ,choose EC2 and create an EC2 instance .Remember to allow http requests through security group. Then connect to it .

EC2 instance

Then install httpd (apache web server) as

sudo yum install httpd

2. Download php application name “WordPress”:

Till now we configured a server (Apache webserver) in EC2 instance.Now install wordpress as

wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz

A new directory named wordpress will be created (If it already exists rename it to allow this one to be created).This will install wordpress latest version i:e 5.6

when php is Installed with yum command it will install php 4.xx.But wordpress needs atleast php5.6.20.Hence install php from amazon-linux-extras repository as

sudo amazon-linux-extras install php7.2

3.Setup MySql server using Amazon RDS:

To set up a mysql RDS goto services choose RDS under Databases and create one with mysql as database engine ,selecting public access .And allow the ip or SG of ec2 instance to connect.

Now create a user and Database to store wordpress data as

CREATE USER ‘wordpress-user’@’localhost’ IDENTIFIED BY ‘your_strong_password’;

CREATE DATABASE `wordpress-db`;

GRANT ALL PRIVILEGES ON `wordpress-db`.* TO “wordpress-user”@”localhost”;

FLUSH PRIVILEGES;

Or use default user admin .

4.Provide the endpoint/connection string to the WordPress:

In the wordpress directory create a conf file using wp-config-sample.php as

cp wordpress/wp-config-sample.php wordpress/wp-config.php

Then give the required DB name,User name password,DB host arguments in the conf file.

wordpress conf file

Then Move the entire wordpress directory under /var/www/html directory

cd /var/www/html

mkdir wp

sudo cp -r wordpress/* /var/www/html/wp/

Now start the httpd service(web server) as

sudo systemctl start httpd

Then enter <ip of EC2 instance>/wp .You will see a welcome page of wordpress as

wordpress welcome page
admin page of wordpress

Finally wordpress is setup and ready to create websites.One issue you will face while using Amazon linux2 EC2 instance is with php version.With amazon-linux-extras repo it will be solved.

--

--