You are on page 1of 17

Installing WordPress blog using apache on EC2 Linux

For hosting a WordPress blog we use AWS EC2 and RDS services. Here the amazon Linux 2
AMI server is being used for hosting the WordPress site and the RDS we will be using is
MySQL. It is also recommended to download putty so that we can use the SSH port 22 for
interacting with our EC2 instance.
1. Since we are using a free tier account, firstly launch the amazon Linux 2 AMI from the
dashboard of various instances.

2. For the instance type, select t2.micro configurations since it is free of cost and enough for
this lab. Next: configure instance details
3. Here assign an IAM role if you want to and select the subnet region you want to choose
or leave it to deploy automatically.

4. Here write the bash configurations for updating our EC2 instance once it starts and also
the WordPress, Apache and PHP configurations. Leave everything else as it is and press
next: Add storage
5. Here select the storage for our instance which is general purpose SSd (GP2) with 8GB
memory and press next: Add tags

6. Add tags as many as you want according to your requirements. Here I have added a tag
for name and its value is “webserver”. Press next: Add security configurations.

7. Here add the default security configuration if it contains ports 22, 80, 443 and 3306 open.
If not you can make a security configuration containing SSH port 22, HTTP port 80,
MySQL port 3306 and HTTPS port 443 so we can communicate with our instance. Press
preview and launch.
8. When you hit launch, a window will appear asking you to create a security key or choose
an existing security key which we are going to use to communicate with our EC2 server.
If you don’t have an existing key, create a new key and give it a name and make sure you
download it. Finally press launch instance.

9. Launch putty key Generator and load the key you downloaded with .pem extension. Save
it as private key with .ppk extension.
10. Now launch putty and go to SSh/auth and choose the private key you generated from
your files.

11. Copy the public Ip address of your instance from the console and copy it. Go to putty and
move down to session and paste the ip in the host name box. Also give the user name
which with you want to login, here I have taken “ec2-user” as my user. Press open.
12. Now navigate back to the AWS console and from services selecct RDS. Here press
create database. We are going to use MySQl 8.0.20 database.
13. Give a name to you database and also the master user name and a strong password to
access the database.
14. Change the instance class to burstable classes and choose db t3.micro. Select the GP2
storage and leave everything as it is.
15. In Public access, select yes so that our WordPress blog can be connected from different
users. Select the security group you chose for your EC2 instance because it contains the
port 3306 for MySQl.
16. This is important. Expand the additional configurations and in database name give the
same name used in the beginning. Leave everything else as it is and scroll down to the
bottom and press create database. Wait for the database till its status shows running.

17. Register your EC2 instance target with the load balancer you should have made. Navigate
back to the EC2 service and select the instance we made. Copy its public Ip address and
open it in a new browser.
18. When you paste the ip address and press enter it should take you to the WordPress
welcome site. This indicates your server is successfully running on apache server with
correct WordPress configurations. Press Let’s go.

19. Enter the MySQL database name followed by the master user and password created in
the database. Press submit.
20. Once you submit, a page will open with a config file code for PHP. Copy the code and
navigate back to your session with EC2 instance in putty. Run sudo su to get root user
access. After that change the working directory to html where all sites are stored
(cd/var/www/html). Create a new “wp-config.php” file and edit it using nano editor.
21. Paste the PHP config file code and save it by pressing by -> ctrl x – Y – enter. Go back
to the browser with WordPress site and press run installation.
22. Give a title to your website, a root user and password for your website and email if you
want. Press submit. You will be redirected to a page where you can authenticate the user
and password you created and log in to your WordPress blog.

23. For accidental deletion or fault tempering purpose, associate your WordPress site with
your load balancers DNS so incase if the server gets destroyed or terminated your site
won’t be affected. It can be them accessed by the same DNS. For doing so, go to settings
from the main web page of your site and change the WordPress URL and Site Address
and press save.
24. Create posts, add media from the menu in the left of the site and publish them. People
visiting your site could see your posts and comment on it.

For more info or help, visit


https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/hosting-wordpress.html

You might also like