How to Setup WordPress on AWS EC2 instance – Part1

Now that we have created an EC2 instance in my earlier post How to Launch my First EC2 instance – Part1, let’s go ahead and install a WordPress software and start building a simple site. To keep our setup very simple, we will do without any VPC or complex security group rules.

What we will do here.

  • Create an Application Tier
    • We will install the apache httpd,WordPress software,php & mysql for php.
  • Create a Database Tier
    • Setup Mysql DB using Amazon RDS, DB tier for the WordPress site.

We can custom install a WordPress on top of the EC2 instance which we have already lanuched as part of How to Launch my First EC2 instance – Part1. As well we can use Amazon’s Lightsail a fully managed service to build/launch a WordPress site.

Now we will start setting up WordPress on top of the EC2 instance.

Note: Whenever you stop and start the EC2 instance, a new public ip will assigned, SSH using the same and connect to instance.

1) Setting up an Application tier (EC2 instance setup):

SSH into your instance and switch to root user and issue below commands in sequence,

Commands Description
Sudo su switch to root user
yum update -y Updates all software patches on the instance.
yum install httpd -y Installs Apache server
cd /var/www/html Go to this directory to download
wordpress software
wget https://wordpress.org/latest.tar.gz Download wordPress s/w
tar -xzf latest.tar.gz Extract the contents
cp -r wordpress/* /var/www/html/ copy the wordPress directory under this directory.
rm -rf wordpress remove the extracted content.
*** This step is optional to save space.
rm -rf latest.tar.gz remove the downloaded zip file.
chmod -R 755 wp-content change the permission of wp-content directory
chown -R apache:apache wp-content make ‘apache’ as the owner of wp-content.
yum -y install php php-mysql Install php software for WordPress.
As well install php-sql.
yum install mysql-server mysql-client install mysql server client aswell.
service httpd start Start the Apache server
chkconfig httpd on Always turn on Apache server.
Save & Exit. Save & Exit.

 

Now, we have successfully configured our EC2 instance(Application tier) with all necessary tools & software’s required to work on WordPress site.

2) Setting up a Database Tier using RDS:

Database -> RDS -> Instances -> Mysql (make sure you click the free tier checkbox checked)

  1. Create a New Database

2.  We will go with all the default setup’s as provided by AWS, including VPC, Security Group.

We have successfully completed DB instance creation.

Next part-2 ‘How to Setup WordPress on AWS EC2 instance – Part2‘  we will look into on how to launch our WordPress Site.

2 thoughts on “How to Setup WordPress on AWS EC2 instance – Part1”

Leave a Reply

Your email address will not be published. Required fields are marked *