RUNBOOK05: UPDATE THE PACKAGES AND INSTALL APACHE ON AN AWS EC2 REDHAT INSTANCE USING A BASH SCRIPT

Sidra J.
3 min readOct 22, 2022

--

Hi tech beauties,

Hope you are having a wonderful Saturday.

So far in this beautiful cloud journey I have introduced you to cloud computing and shown you how to

In this post I will show you how to write a bash script to update the software packages on an EC2 instance and install Apache. It is the same exact thing that we did here but we will be using a script instead so we don’t have to manually run the commands going forward

After connecting to my RedHat Linux EC2 instance, I will be in the home directory and will create two files.

The first file is index.html

vi /home/ec2-user/index.html

The second file is the bash script. A Bash script is a plain text file which contains a series of commands.

The bash script will have the command to update the software using yum on a new EC2 Instance, install httpd, start httpd and copy index.html from /home/ec2-user/ to /var/www/html/

vi /home/ec2-user/script.sh

I ran the script using super user privileges and piped the output to log.txt.

sudo sh script.sh > log.txt

Once the command finished I went to the public IPv4 address as listed in the EC2 Dashboard for this instance and was able to view the web page

http://54.91.63.66

This was a fun project and a great refresher on AWS for me. I was able to use my Linux skills as well. Thank you for joining me on this AWS Journey.

Sidra Javed (MSc, DIT 2023, ITILv3)

Cloud Engineer | DevOps Engineer | SRE | Production Application Support

LinkedIn | Tech Blog | GitHub | Schedule Time

--

--

Sidra J.

#womanintech #womaninstem #womaninit #womenempowerment #rebel #ladyengineer#muslim #fintech #cloud#devops #morganstanley