Linux Server Circus: Juggling Bytes and Bandwidth

Paul Lavecchia
5 min readFeb 20, 2024

--

Hello all or anyone that comes to read this project! Hosting a server may seem daunting but we are going to show you how with these objectives/goals in mind:

  • Spin up a Linux instance in AWS
  • Enables SSH,HTTP and HTTPS traffic to our instance.
  • Make sure our instance is up to date with all of the most recent packages.
  • Install an Apache Web Server and enable it

Let’s give some LORE to this activity. You are hired as a Junior Cloud Engineer for a Bank and your Director asked you to prep a website server on Linux on the AWS account.

Lets start by going to AWS logging into your Admin account and going to the EC2 section, Instances and Launch an Instance.

You should be here!

For this exercise we are going to use CentOS as the flavor of Linux . When going through the “Quick Start” you’ll realize that there is no CentOS but that is okay we will go to “Browse more AMIs” to find it.

We are going to look up CentOS in the search bar and pick the one that fits your need, you should be here:

See if you can match your configuration to mine.

Now we are going to make sure our EC@ is accessible by SSH by needing a specific Key Pair which we will generate!

You’ll need to click on the “Create new Key pair” and you should match my key pair configurations (If you are on Windows 10 and up). Please see here:

You have to Click on the Blue print to the right to create a new and unique key.
This should by default download to your download folder . Click Create Key Pair when done ^^^

Now we want to ensure that HTTP and HTTPS traffic is allowed as we are … you know going to host a Web Server…. surely no one has ever made that mistake (me… I have made that mistake) so make sure you allow it like this :

If this is correct you may launch your instance which you see ^above^

and if there is no issues you should see that beautiful green banner!

this is AWS label for your instance in the green banner , Click this!

When you are viewing your instance click “Connect” in the top right.

Now go to the SSH Tab and you should have this instructions:

Now I am all about speed and efficiency… and not having to type things you don’t need to if you hit “Copy and paste”. With that being said please pull up File Explore and go to download or wherever your Key Downloaded to. Go to the File Directory where it is stored and right click the directory and click copy address.

Right Click on “Downloads” and click “Copy Address”

Now open up Power Shell and run as admin. We are going to “CD” (Change Directory) into your directory where your key is save so type “cd” then click “Ctrl-V”! We copied the already path and don’t have to type that whole path out!

We are going to follow the previous picture directions and copy the command and paste it.

chmod 400 "linux_project.pem"

We use this to ensure that the key is seen publicly at all!

Now we copy the “Example “ and paste it, it should look like this:

The .pem should be different unless you named it exactly that LOL

You will be prompted with a Y/N request click “Y”

Now you should receive confirmation you are connected as seen here :

“Permission Denied….. on no”

You didnt connect… that’s it pack it up you faile…. oh wait!

*Forehead slap*

You (me) forgot to chnage the user name!!

In this ssh command we want to change the “ec2-user” to “centos”

When you do that you run the command and you will have to type “Y” again and …..

WE ARE IN!

So for security reasons we want to ensure that this version of CentOS that was posted is up to date and has all the patches! How would you feel if the bank you used had a website you accessed your accounts with was out of date and had a bunch of vulnerabilities? Exactly, this is quite crucial.

We are going to run “sudo yum update” it will again prompt you “Y/N” you will again click “Y”. You should see “Complete!”

We are going to install a Webserver called Apache, thankfully this will all be ran in the CLI.

The Command is “sudo yum install httpd”. If we have learned anything we will know that “Y/N” will be the next prompt which it will be. Type “Y” and you will get “Complete!

The next commands you will run are these and please run them one by one in this order :

sudo systemctl start httpd
sudo systemctl enable httpd.service

Without errors it should like like this:

WE DID IT (AGAIN)!

Time for the real test to see if we can access this using HTTP/HTTPS.

Go back to your Instance on AWS and locate the Public IPv4 address, copy it and paste it in your browser.

The ^IPv4^ is located near the top for the specific instance your are hosting this on.

Here is mine : 44.211.204.121 v

See if you get this page :

Thank you again for taking time to read this as well as coming along on this adventure into the Cloud!!

--

--