Launching Wordpress with AWS
What is WordPress?
WordPress (WP, WordPress.org) is a free and open-source content management system (CMS) written in PHP and paired with a MySQL or MariaDB database. Features include a plugin architecture and a template system, referred to within WordPress as Themes. WordPress was originally created as a blog-publishing system but has evolved to support other web content types including more traditional mailing lists and forums, media galleries, membership sites, learning management systems (LMS) and online stores.
To function, WordPress has to be installed on a web server, either part of an Internet hosting service like WordPress.com or a computer running the software package WordPress.org in order to serve as a network host in its own right.
Pre-requisites
- Must have account on aws
Now we are ready to go ..
Step 1 : Create an AWS EC2 instance
Login to AWS Account.
Go to EC2 Dashboard ->> instances ->> Launch Instance

a) Select an AMI. Here I am selecting Amazon Linux 2 AMI.

b) Click next and Select the Instance Type. I’ll go for default one.

c) Configure Instance Details

d) Add Storage

e) Add Tags
Here we can create multiple tags like name, env etc. These tags are helpful to specify the instance.

f) Configure Security Group — Here I am adding one more rule for HTTP and allowing everyone to connect with the instance.
Note: It is not a good practice to allow everyone. We must create custom rules for the security of our instances.
( I have done this just for the demo )

g) Review and Launch
Now, If we want to connect with this instance using the ssh protocol we need a key so here I am attaching an existing key. You can create a new one.

Here we can see, the instance is up !!

So the step 1 is done. Now move to the step 2 ..
Step 2 : Configure the instance with Apache Webserver
Let’s connect with the instance. There are so many ways to connect with the instance
- Using the browser
- Using ssh
- Using the software like putty etc.
Here I am using the first way. You can choose any one of the above.

Note: All the images do not provide this option to connect.
Currently we login as ec2-user. This user doesn’t have the admin power so to switch with root user, run the below command
sudo su -Let’s Configure Apache Webserver !!
a) Install the Software
yum install httpd -yb) Start the service and make it permanent
systemctl start httpd
systemctl enable httpdHere we can see, it is successfully configured

Step 3 : Download PHP application name “WordPress”.
Requirements
- PHP version 7.4 or greater.
- MYSQL version 5.6 or greater OR MariaDB version 10.1 or greater.
- HTTPS support
- Install PHP
To install php on Amazon Linux 2, we have to first install amazon-linux-extras package. ( By default, it is installed )
yum install -y amazon-linux-extras
Enable PHP 7.4 package
amazon-linux-extras enable php7.4Now install PHP packages from the repository.
yum clean metadata yum install php php-{pear,cgi,common,curl,mbstring,gd,mysqlnd,gettext,bcmath,json,xml,fpm,intl,zip,imap}
We can see the installed version of PHP using the below command
php -v2. Download and extract the software
wget https://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz
3. Upload the WordPress files in the root directory of webserver
Note: Here I am using Apache webserver so the root directory of the webserver is /var/www/html
cp -r wordpress/* /var/www/html/
WordPress is installed !!
We can check it by go to the url
http://<public_ip_of_server>/wp-admin/install.php

Here it will ask for the Database Information so we need to create a DataBase.
I am creating MYSQL Database using AWS RDS, you can use MariaDB or other databases also as per the requirement.
Step 4: Setup a MySQL server using AWS RDS service using Free Tier.
Go to AWS RDS Service →> Create Database

Select MariaDB Engine

Templates ->> Free Tier ( You can select as per your requirement )
Settings ->> Set the Database name, Database User Name and the password

Note: Whatever password you set for database, it should be remembered. As we need it in the future.
Give database a name !

- Public Accessibility — yes
- Security Group — AllowAll ( You can customize it )
I Go for the default settings and create the Database for this task.

Our database is created. We’ll use this endpoint to connect with wordpress.
Step 5: Provide the endpoint/connection string to the WordPress application to make it work.

Or we can manually write these information in the wp-config-sample.php file and rename this file with wp-config.php
mv wp-config-sample.php wp-config.phpSet Some Basic Information and click on the Installation.

After Successfully Login you will see the Dashboard of WordPress

Now we can write the blogs and post them.

Hope you find this Article Helpful.
Thanks for Reading :)
Comments
Post a Comment